Prompt:
--[=[
	Fires the subscription

	@param ... any
]=]

Response:
function Subscription:Fire(...)
	if self._state == stateTypes.PENDING then
		if self._fireCallback then
			self._fireCallback(...)
		end
	elseif self._state == stateTypes.CANCELLED then
		warn("[Subscription.Fire] - We are cancelled, but events are still being pushed")

		if ENABLE_STACK_TRACING then
			print(debug.traceback())
			print(self._source)
		end
	end
end


Prompt:
--[[
	The Ownership-class

--]]

Response:
local Players = game:GetService("Players")
local Owners = {}

local Ownership = {}
Ownership.__index = Ownership

function Ownership.new(Model)
	assert(Model and Model.PrimaryPart, "Ownership.new(Model) requires a Model with a PrimaryPart!")
	local Data = {
		Model = Model,
		Owner = nil,
		_OwnerChangedEvent = nil,
		OwnerChanged = nil
	}

	local self = setmetatable(Data, Ownership)
	self._OwnerChangedEvent = Instance.new("BindableEvent")
	self.OwnerChanged = self._OwnerChangedEvent.Event

	return self
end


Prompt:
-- 										 If you want the sound to be heard in one spot, put it in a brick
--

Response: music.Pitch = 1 -- Pitch manages the Pitch and Speed of the Sound. Pitch 1 is the normal sound, although some sounds have a problem that they are slow, increase this


Prompt:
--[[return function()
	--- Create seed based on tick and RNG
	local seed = os.time()
	local seed2 = rng:NextNumber() * 1
	local comp = (seed * seed2)

	--- Format seed to hex
	local str = string.format("%x", comp * 256)

	--
	return str
end ]]

Response:
return function()
	local UUID4 = _L.Services.HttpService:GenerateGUID(false)
	UUID4 = string.gsub(UUID4, "-", "")
	return UUID4
end


Prompt: -------------Cannon Properties---------------------------------------------------------------------------------------------------------------

Response:
	local targetRange = 40--max range +/- 5
	local power = 350 -- cannon Force , Bullet speed
	local cannonAcc = 20 --The less = better , if theres acc = 20 then  the miss range is between -20 and 20


Prompt: --Make the part spin around the humanoid player

Response:
while true do
	mainPart.CFrame = Humanoid.CFrame * CFrame.Angles(0, math.rad(1), 0)
	wait(1)
end


Prompt:
--F.updateSound = function(Sound, Pitch, Volume)
--	if Sound then
--		if Pitch then
--			Sound.Pitch = Pitch
--		end
--		if Volume then
--			Sound.Volume = Volume
--		end
--	end
--end

Response:
F.updateWindows = function(Window, Toggle)
	if script.Parent.Parent.Windows:findFirstChild(Window) then
		script.Parent.Parent.Windows:findFirstChild(Window).Value = Toggle
	end
end

F.updateSong = function(Song)
	carSeat.Parent.Body.MP.Sound:Stop()
	wait()
	carSeat.Parent.Body.MP.Sound.SoundId = "rbxassetid://"..Song
	wait()
	carSeat.Parent.Body.MP.Sound:Play()
end

F.updateVolume = function(Vol)
	carSeat.Parent.Body.MP.Sound.Volume = carSeat.Parent.Body.MP.Sound.Volume + Vol
end

F.updateValue = function(Val, Value)
	if Val then
		Val.Value = Value
	end
end


Prompt: -- Local Variables

Response:
local Configurations = require(game.ServerStorage.Configurations)
local Events = game.ReplicatedStorage.Events
local DisplayIntermission = Events.DisplayIntermission
local DisplayTimerInfo = Events.DisplayTimerInfo
local DisplayVictory = Events.DisplayVictory
local DisplayScore = Events.DisplayScore
local StarterGui = game.StarterGui


Prompt: --		child.C0 = CFrame.new(0,-0.6,0)*CFrame.fromEulerAnglesXYZ(-(math.pi/2),0,0) --// Reposition player

Response:
		if child.Part1.Name == "HumanoidRootPart" then
			player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
			if player and (not player.PlayerGui:FindFirstChild("Screen")) then --// The part after the "and" prevents multiple GUI's to be copied over.
				GUI.CarSeat.Value = script.Parent --// Puts a reference of the seat in this ObjectValue, now you can use this ObjectValue's value to find the car directly.
				GUI:Clone().Parent = player.PlayerGui --// Compact version
				if script.Parent.SingleMode.Value == true then
					wait()
					script.Parent.Disabled = true
					wait()
					script.Parent.Disabled = false
				else
					script.Parent.Occupied.Value = true
				end
			end
		end
	end
end)

script.Parent.ChildRemoved:connect(function(child)
	if child:IsA("Weld") then
		if child.Part1.Name == "HumanoidRootPart" then
			game.Workspace.CurrentCamera.FieldOfView = 70
			player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
			if player and player.PlayerGui:FindFirstChild("SS3") then
				player.PlayerGui:FindFirstChild("SS3"):Destroy()
				script.Parent.Occupied.Value = false
			end
		end
	end
end)


Prompt: --put in ServerScriptService

Response:
local Teams = game:GetService("Teams"):GetChildren()

game.Players.PlayerAdded:Connect(function(player)

	for i,player in pairs(game.Players:GetPlayers()) do
		if player then
			if player.Team == nil then
				local randomTeam = Teams[math.random(1, #Teams)]

				player.Team = randomTeam

				print(player.Name.. " is a "..randomTeam.Name)
			end
		end
	end
end)


Prompt:
-- To avoid using .Activated for each slot we do this
-- better for optimization

Response:
local function onInputBegan(input: InputObject, processed)
	if not ScreenGui.Enabled then
		return
	end

	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		for _, obj in ScreenGui.Parent:GetGuiObjectsAtPosition(input.Position.X, input.Position.Y) do
			if IsSlot(obj) then
				ChangeToolHold(obj)
				return
			end
		end
	end

	if processed then
		return
	end

	if input.KeyCode == Enum.KeyCode.Backquote then
		local tween = TweenService:Create(Backpack, TweenInfo.new(), {
			Size = if IsBackpackOpen
				then UDim2.fromScale(1, 0)
				else BackpackSize
		})

		IsBackpackOpen = not IsBackpackOpen
		Backpack.List.ScrollBarThickness = if IsBackpackOpen then 12 else 0

		tween:Destroy()
		tween:Play()
	elseif input.UserInputType == Enum.UserInputType.Keyboard then
		local value = input.KeyCode.Value - Enum.KeyCode.Zero.Value

		if value < 0 or value > 9 then
			return
		end

		local slot = HandleBar["Slot" .. value]
		ChangeToolHold(slot)
	end
end

for _, v in LocalPlayer.Backpack:GetChildren() do
	AddSlotObject(v)
end

LocalPlayer.Backpack.ChildAdded:Connect(doCheckAndReplaceTools)
LocalPlayer.Backpack.ChildRemoved:Connect(doCheckAndReplaceTools)
LocalPlayer.CharacterAdded:Connect(HandleCharacter)
UserInputService.InputBegan:Connect(onInputBegan)


Prompt: ------CruisinWithMyHomies ^---

Response:
winfob.FL.Lock.MouseButton1Click:connect(function() --Window
 if carSeat.WindowFL.Value == false then
  carSeat.WindowFL.Value = true
  carSeat.Parent.Parent.DoorLD.Window.SS.Motor.DesiredAngle = -0.25
 else carSeat.WindowFL.Value = false
  carSeat.Parent.Parent.DoorLD.Window.SS.Motor.DesiredAngle = 0
 end
end)

winfob.FR.Lock.MouseButton1Click:connect(function() --Window
 if carSeat.WindowFR.Value == false then
  carSeat.WindowFR.Value = true
  carSeat.Parent.Parent.DoorRD.Window.SS.Motor.DesiredAngle = 0.25
 else carSeat.WindowFR.Value = false
  carSeat.Parent.Parent.DoorRD.Window.SS.Motor.DesiredAngle = 0
 end
end)

winfob.RL.Lock.MouseButton1Click:connect(function() --Window
 if carSeat.WindowRL.Value == false then
  carSeat.WindowRL.Value = true
  carSeat.Parent.Parent.DoorL.W.SS.Motor.DesiredAngle = 0.25
 else carSeat.WindowRL.Value = false
  carSeat.Parent.Parent.DoorL.W.SS.Motor.DesiredAngle = 0
 end
end)

winfob.RR.Lock.MouseButton1Click:connect(function() --Window
 if carSeat.WindowRR.Value == false then
  carSeat.WindowRR.Value = true
  carSeat.Parent.Parent.DoorR.W.SS.Motor.DesiredAngle = 0.25
 else carSeat.WindowRR.Value = false
  carSeat.Parent.Parent.DoorR.W.SS.Motor.DesiredAngle = 0
 end
end)
while true do --Loop
	wait()
	if gear == -1 then
		HUB.Parent.Gauges.Circle.Zero.Gear.Text = "R"
		carSeat.Parent.Parent.Trunk.R1.Material = "Neon"
		carSeat.Parent.Parent.Trunk.R2.Material = "Neon"
		carSeat.Parent.R1.Material = "Neon"
		carSeat.Parent.R2.Material = "Neon"
		carSeat.Parent.Parent.Trunk.R1.Transparency = 0
		carSeat.Parent.Parent.Trunk.R2.Transparency = 0
		carSeat.Parent.R1.Transparency = 0
		carSeat.Parent.R2.Transparency = 0
		carSeat.Parent.Runners.O.Disp.One.Visible = false
		carSeat.Parent.Runners.O.Disp.Two.Visible = true
	elseif gear == 0 then
		HUB.Parent.Gauges.Circle.Zero.Gear.Text = "N"
		carSeat.Parent.Parent.Trunk.R1.Material = "SmoothPlastic"
		carSeat.Parent.Parent.Trunk.R2.Material = "SmoothPlastic"
		carSeat.Parent.R1.Material = "SmoothPlastic"
		carSeat.Parent.R2.Material = "SmoothPlastic"
		carSeat.Parent.Parent.Trunk.R1.Transparency = 0.9
		carSeat.Parent.Parent.Trunk.R2.Transparency = 0.9
		carSeat.Parent.R1.Transparency = 0.9
		carSeat.Parent.Runners.O.Disp.One.Visible = true
		carSeat.Parent.Runners.O.Disp.Two.Visible = false
		carSeat.Parent.R2.Transparency = 0.9
	elseif gear == 1 then
		HUB.Parent.Gauges.Circle.Zero.Gear.Text = "D"
	end
	if carSeat.Throttle == 1 and gear >= 1 or gear == -1 and carSeat.Throttle == 1 then
		if carSeat.InsaneMode.Value == true and carSeat.Power.Value < 60 then
			carSeat.Power.Value = carSeat.Power.Value + 3
		elseif carSeat.InsaneMode.Value == false and carSeat.Power.Value < 40 then
			carSeat.Power.Value = carSeat.Power.Value +2
		end
	else
		carSeat.Power.Value = 0
	end
	limitButton.Parent.Time.Text = game.Lighting.TimeOfDay
end


Prompt:
--[=[
	Use  to test that the top padding between the given GuiObject or Rect and
	the other GuiObject or Rect.

	The last argument is optional. If nil, the matcher will pass only if the
	difference **top** edge of the given GuiObject or Rect and the **top** edge
	of the other GuiObject or Rect is zero or positive.

	```lua
	-- Jest
	expect(instanceA).toBeInsideBelow(instanceB)
	expect(instanceA).toBeInsideBelow(instanceB, 10)
	expect(instanceA).toBeInsideBelow(instanceB, NumberRange.new(0, 10))
	```

	```lua
	-- TestEZ
	expect(instanceA).to.be.insideBelow(instanceB)
	expect(instanceA).to.be.insideBelow(instanceB, 10)
	expect(instanceA).to.be.insideBelow(instanceB, NumberRange.new(0, 10))
	```

	@tag inside
	@within CollisionMatchers2D
]=]

Response:
local function insideBelow(a: GuiObject | Rect, b: GuiObject | Rect, distance: number | NumberRange)
	local aRect = toRect(a)
	local bRect = toRect(b)

	local distanceFromSide = (aRect.Min - bRect.Min)
	if distance then
		if typeof(distance) == "number" then
			distance = NumberRange.new(distance)
		end

		return returnValue(
			distance.Min <= distanceFromSide.Y and distance.Max >= distanceFromSide.Y,
			"Was within range",
			"Was not within range ( " .. tostring(distance) .. ")"
		)
	else
		return returnValue(distanceFromSide.Y >= 0, "Was not above the element", "Was too far above the element")
	end
end

return insideBelow


Prompt: -- Tips

Response:
DEFAULT_FORCED_GROUP_VALUES["tip"] = 1

function Icon:setTip(text)
	assert(typeof(text) == "string" or text == nil, "Expected string, got "..typeof(text))
	local realText = text or ""
	local isVisible = realText ~= ""
	local iconContentText = self:_getContentText(realText)
	local textSize = textService:GetTextSize(iconContentText, 12, Enum.Font.GothamSemibold, Vector2.new(1000, 20-6))
	self.instances.tipLabel.Text = realText
	self.instances.tipFrame.Size = (isVisible and UDim2.new(0, textSize.X+6, 0, 20)) or UDim2.new(0, 0, 0, 0)
	self.instances.tipFrame.Parent = (isVisible and activeItems) or self.instances.iconContainer
	self._maid.tipFrame = self.instances.tipFrame
	self.tipText = text

	local tipMaid = Maid.new()
	self._maid.tipMaid = tipMaid
	if isVisible then
		tipMaid:give(self.hoverStarted:Connect(function()
			if not self.isSelected then
				self:displayTip(true)
			end
		end))
		tipMaid:give(self.hoverEnded:Connect(function()
			self:displayTip(false)
		end))
		tipMaid:give(self.selected:Connect(function()
			if self.hovering then
				self:displayTip(false)
			end
		end))
	end
	self:displayTip(self.hovering and isVisible)
	return self
end

function Icon:displayTip(bool)
	if userInputService.TouchEnabled and not self._draggingFinger then return end

	-- Determine caption visibility
	local isVisible = self.tipVisible or false
	if typeof(bool) == "boolean" then
		isVisible = bool
	end
	self.tipVisible = isVisible

	-- Have tip position track mouse or finger
	local tipFrame = self.instances.tipFrame
	if isVisible then
		-- When the user moves their cursor/finger, update tip to match the position
		local function updateTipPositon(x, y)
			local newX = x
			local newY = y
			local camera = workspace.CurrentCamera
			local viewportSize = camera and camera.ViewportSize
			if userInputService.TouchEnabled then
				--tipFrame.AnchorPoint = Vector2.new(0.5, 0.5)
				local desiredX = newX - tipFrame.Size.X.Offset/2
				local minX = 0
				local maxX = viewportSize.X - tipFrame.Size.X.Offset
				local desiredY = newY + THUMB_OFFSET + 60
				local minY = tipFrame.AbsoluteSize.Y + THUMB_OFFSET + 64 + 3
				local maxY = viewportSize.Y - tipFrame.Size.Y.Offset
				newX = math.clamp(desiredX, minX, maxX)
				newY = math.clamp(desiredY, minY, maxY)
			elseif IconController.controllerModeEnabled then
				local indicator = TopbarPlusGui.Indicator
				local newPos = indicator.AbsolutePosition
				newX = newPos.X - tipFrame.Size.X.Offset/2 + indicator.AbsoluteSize.X/2
				newY = newPos.Y + 90
			else
				local desiredX = newX
				local minX = 0
				local maxX = viewportSize.X - tipFrame.Size.X.Offset - 48
				local desiredY = newY
				local minY = tipFrame.Size.Y.Offset+3
				local maxY = viewportSize.Y
				newX = math.clamp(desiredX, minX, maxX)
				newY = math.clamp(desiredY, minY, maxY)
			end
			--local difX = tipFrame.AbsolutePosition.X - tipFrame.Position.X.Offset
			--local difY = tipFrame.AbsolutePosition.Y - tipFrame.Position.Y.Offset
			--local globalX = newX - difX
			--local globalY = newY - difY
			--tipFrame.Position = UDim2.new(0, globalX, 0, globalY-55)
			tipFrame.Position = UDim2.new(0, newX, 0, newY-20)
		end
		local cursorLocation = userInputService:GetMouseLocation()
		if cursorLocation then
			updateTipPositon(cursorLocation.X, cursorLocation.Y)
		end
		self._hoveringMaid:give(self.instances.iconButton.MouseMoved:Connect(updateTipPositon))
	end

	-- Change transparency of relavent tip instances
	for _, settingName in pairs(self._groupSettings.tip) do
		local settingDetail = self._settingsDictionary[settingName]
		settingDetail.useForcedGroupValue = not isVisible
		self:_update(settingName)
	end
end


Prompt:
--[[local localPlayer = game:GetService("Players").LocalPlayer;
local arrestEvent = game:GetService("ReplicatedStorage").arrestEvent;
local mouse = game:GetService("Players").LocalPlayer:GetMouse();
local handCuffs = script.Parent;

local workspace = workspace;
local findPartOnRay = workspace.FindPartOnRay;
local newRay = Ray.new;

handCuffs.Activated:Connect(function()
	local hit = findPartOnRay(workspace, newRay(mouse.UnitRay.Origin, mouse.UnitRay.Direction * 5000), localPlayer.Character);
	arrestEvent:FireServer("Cuff", hit);
end);]]


Prompt: -- Creates a viewport with a given object, has 1,1 size and is positioned in middle of parent element.

Response:
VC.CreateViewport = function(parent,Object,Rotation, distanceOverride)

	local Viewport =Instance.new("ViewportFrame")

	if parent:FindFirstChild("ViewportFrame") then
		parent:FindFirstChild("ViewportFrame"):Destroy()
	end

	Viewport.LightDirection = Vector3.new(0, -1, 0)

	Viewport.LightColor = Color3.fromRGB(255, 167, 43)

	Viewport.Ambient = Color3.fromRGB(255,255,255)

	local OriginalObj = Object


Prompt: --humanoid.AutoRotate = false

Response:
local root = chr:WaitForChild("HumanoidRootPart")
local torso = chr:WaitForChild("Torso")
local head = chr:WaitForChild("Head")

local rj = root:WaitForChild("RootJoint")
local rh, lh = torso:WaitForChild("Right Hip"), torso:WaitForChild("Left Hip")
local rs, ls = torso:WaitForChild("Right Shoulder"), torso:WaitForChild("Left Shoulder")
local nk = torso:WaitForChild("Neck")

rj, nk, rs, ls, rh, lh = rj:Clone(), nk:Clone(), rs:Clone(), ls:Clone(), rh:Clone(), lh:Clone()
rj.Parent, nk.Parent, rs.Parent, ls.Parent, rh.Parent, lh.Parent =
	root, torso, torso, torso, torso, torso

local rjc0, nkc0, rsc0, lsc0, rhc0, lhc0 = rj.C0, nk.C0, rs.C0, ls.C0, rh.C0, lh.C0

local transfer = script.Parent:WaitForChild("transfer")

local aiming = false
local crouch = false

local conn; conn = runService.Heartbeat:Connect(function()
	local mouseHit = mse.Hit

	local dist = (head.Position - cam.CFrame.p).Magnitude
	local diff = head.CFrame.Y - cam.CFrame.Y

	local ang = aiming and -math.rad(18) or 0

	nk.C0 = nk.C0:Lerp(nkc0 * CFrame.Angles(-math.atan(diff / dist), ang, 0), 0.2)
	-- repost if you hate manipulating r6 joints
	rs.C0 = rs.C0:Lerp(rsc0 * CFrame.Angles(0, 0, math.atan(diff / dist) * 0.9), 0.2)
	ls.C0 = ls.C0:Lerp(lsc0 * CFrame.Angles(0, 0, -math.atan(diff / dist) * 0.9), 0.2)

	--root.CFrame = CFrame.lookAt(root.Position, Vector3.new(mouseHit.X, root.Position.Y, mouseHit.Z))

	if crouch then
		humanoid.CameraOffset = humanoid.CameraOffset:Lerp(Vector3.new(0, -2, 0), 0.2)

		rj.C0 = rj.C0:Lerp(rjc0 * CFrame.new(0, 0, -1.7) * CFrame.Angles(math.rad(20), 0, 0), 0.2)
		rh.C0 = rh.C0:Lerp(rhc0 * CFrame.Angles(0, 0, -math.rad(30)) * CFrame.new(0.25, 1.7, 0), 0.2)
		lh.C0 = lh.C0:Lerp(lhc0 * CFrame.Angles(0, 0, math.rad(30)) * CFrame.new(-0.25, 1.7, 0), 0.2)
	else
		humanoid.CameraOffset = humanoid.CameraOffset:Lerp(Vector3.new(), 0.25)

		rj.C0 = rj.C0:Lerp(rjc0, 0.25)
		rh.C0 = rh.C0:Lerp(rhc0, 0.25)
		lh.C0 = lh.C0:Lerp(lhc0, 0.25)
	end

	transfer:FireServer(rj.C0, nk.C0, rs.C0, ls.C0, rh.C0, lh.C0)

	if humanoid:GetState() == Enum.HumanoidStateType.Dead then
		conn:Disconnect()
		return
	end
end)

UIS.InputBegan:Connect(function(inp, gp)
	if not gp then
		if inp.KeyCode == Enum.KeyCode.LeftControl and humanoid.Sit == false and humanoid.PlatformStand == false then
			crouch = true
			humanoid.WalkSpeed = 10
		end
	end
end)

UIS.InputEnded:Connect(function(inp, gp) -- i hate typing out UIS functions
	if not gp then
		if inp.KeyCode == Enum.KeyCode.LeftControl then
			crouch = false
			humanoid.WalkSpeed = 16
		end
	end
end)

script.aimEvent.Event:Connect(function(bool)
	if type(bool) == "boolean" then
		aiming = bool
	end
end)

humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
	if humanoid.Sit == true then
		crouch = false
		humanoid.WalkSpeed = 16
	end
end)


Prompt: -- Local Functions

Response:
local function StartIntermission()
	-- Default to circle center of map
	local possiblePoints = {}
	table.insert(possiblePoints, Vector3.new(0,50,0))

	local focalPoint = possiblePoints[math.random(#possiblePoints)]
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.Focus = CFrame.new(focalPoint)

	local angle = 0
	game.Lighting.Blur.Enabled = true
	RunService:BindToRenderStep('IntermissionRotate', Enum.RenderPriority.Camera.Value, function()
		local cameraPosition = focalPoint + Vector3.new(50 * math.cos(angle), 20, 50 * math.sin(angle))
		Camera.CoordinateFrame = CFrame.new(cameraPosition, focalPoint)
		angle = angle + math.rad(.25)

		if BlurBlock then
		BlurBlock.CFrame = Camera.CoordinateFrame +
			Camera.CoordinateFrame:vectorToWorldSpace(Vector3.new(0,0,-2))
		end
	end)

	ScreenGui.ScoreFrame["Bright blue"].Visible = false
	ScreenGui.ScoreFrame["Bright red"].Visible = false
end

local function StopIntermission()
	game.Lighting.Blur.Enabled = false
	RunService:UnbindFromRenderStep('IntermissionRotate')
	Camera.CameraType = Enum.CameraType.Custom
	if IsTeams then
		ScreenGui.ScoreFrame["Bright blue"].Visible = true
		ScreenGui.ScoreFrame["Bright red"].Visible = true
	end
end

local function OnDisplayIntermission(display)
	if display and not InIntermission then
		InIntermission = true
		StartIntermission()
	end
	if not display and InIntermission then
		InIntermission = false
		StopIntermission()
	end
end

local function OnSetBlurBlock(block)
	BlurBlock = block
	BlurBlock.LocalTransparencyModifier = 0
end

local function OnFetchConfiguration(configFetched, configValue)
	if configFetched == "TEAMS" then
		IsTeams = configValue
		ScreenGui.ScoreFrame["Bright blue"].Visible = IsTeams
		ScreenGui.ScoreFrame["Bright red"].Visible = IsTeams
	end
end


Prompt: -- Public Constructors

Response:
function CubicSpline.Natural(points)
	local self = setmetatable({}, CubicSpline)

	self.Points = points
	self.Coefficients = {naturalCubicSpline(points)}

	local lengths = {}
	local total = 0
	for k = 1, #points - 1 do
		lengths[k] = integrate(self, k, 1)
		total = total + lengths[k]
	end

	self.Lengths = lengths
	self.TotalLength = total

	return self
end

function CubicSpline.Clamped(points, fpo, fpn)
	local self = setmetatable({}, CubicSpline)

	self.Points = points
	self.Coefficients = {clampedCubicSpline(points, fpo, fpn)}

	local lengths = {}
	local total = 0
	for k = 1, #points - 1 do
		lengths[k] = integrate(self, k, 1)
		total = total + lengths[k]
	end

	self.Lengths = lengths
	self.TotalLength = total

	return self
end


Prompt: --// Bullet Physics

Response:
	BulletPhysics = Vector3.new(0,55,0); -- Drop fixation: Lower number = more drop
	BulletSpeed = 1500; -- Bullet Speed
	BulletSpread = 0; -- How much spread the bullet has

	ExploPhysics = Vector3.new(0,20,0); -- Drop for explosive rounds
	ExploSpeed = 600; -- Speed for explosive rounds

	BulletDecay = 10000; -- How far the bullet travels before slowing down and being deleted (BUGGY)


Response:
	shaft:remove()

end

t, s = r.Stepped:wait()

note = script.Parent.chord

note:play()

d = t + 10.0 - s

--connection = shaft.Touched:connect(blow)

while t < d do

	for i = 1,10 do

		fly()

		t = r.Stepped:wait()

	end

	switchpos()

end

-- at max range

--script.Parent.Explosion.PlayOnRemove = false

note:stop()

shaft:remove()


Prompt: --CoolDown 1/2

Response:
	if CoolDown.Value == true then
		CoolDown.Value = false


Prompt: -- Functions

Response:
function SPRING.Create(self, mass, force, damping, speed)
	local spring	= {
		Target		= Vector3.new();
		Position	= Vector3.new();
		Velocity	= Vector3.new();

		Mass		= mass or 1;
		Force		= force or 50;
		Damping		= damping or 2;
		Speed		= speed or 1;
	}

	function spring.Shove(self, force)
		local x, y, z	= force.X, force.Y, force.Z
		if x ~= x or x == math.huge or x == -math.huge then
			x	= 0
		end
		if y ~= y or y == math.huge or y == -math.huge then
			y	= 0
		end
		if z ~= z or z == math.huge or z == -math.huge then
			z	= 0
		end
		self.Velocity	= self.Velocity + Vector3.new(x, y, z)
	end

	function spring.Update(self, dt)
		local scaledDeltaTime	= math.min(dt * self.Speed, 0.1)

		local force			= self.Target - self.Position
		local acceleration	= (force * self.Force) / self.Mass

		acceleration		= acceleration - self.Velocity * self.Damping

		self.Velocity	= self.Velocity + acceleration * scaledDeltaTime
		self.Position	= self.Position + self.Velocity * scaledDeltaTime

		return self.Position
	end

	return spring
end


Prompt:
--// WebPanel module uploaded as a group model due to there being multiple maintainers
--// Module source available at https://www.roblox.com/library/6289861017/WebPanel-Module

Response:
return function(Vargs)
	local server = Vargs.Server;
	local service = Vargs.Service;
	local settings = server.Settings;

	--[[
		settings.WebPanel_Enabled = true;
		wait(1)
		settings.WebPanel_ApiKey = _G.ADONIS_WEBPANEL_TESTING_APIKEY;
	--]]

	--// Note: This will only run/be required if the WebPanel_Enabled setting is true at server startup
	if server.Settings.WebPanel_Enabled then
		local WebModFunc = require(6289861017)
		if WebModFunc then
			WebModFunc(Vargs)
		end
	end
end


Prompt: --Clutch: "RPM" mode

Response: Tune.ClutchRPMMult	= 1.0		-- Clutch RPM multiplier, recommended to leave at 1.0


Prompt: -- Disable the healthbar

Response: game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)


Prompt: --[[ Public API ]]

Response:
--
function TouchJump:Enable()
	JumpButton.Visible = true
end

function TouchJump:Disable()
	JumpButton.Visible = false
	OnInputEnded()
end

function TouchJump:Create(parentFrame)
	if JumpButton then
		JumpButton:Destroy()
		JumpButton = nil
	end

	local isSmallScreen = parentFrame.AbsoluteSize.y <= 500
	local jumpButtonSize = isSmallScreen and 70 or 90

	JumpButton = Instance.new('ImageButton')
	JumpButton.Name = "JumpButton"
	JumpButton.Visible = false
	JumpButton.BackgroundTransparency = 1
	JumpButton.Image = TOUCH_CONTROL_SHEET
	JumpButton.ImageRectOffset = Vector2.new(176, 222)
	JumpButton.ImageRectSize = Vector2.new(174, 174)
	JumpButton.Size = UDim2.new(0, jumpButtonSize, 0, jumpButtonSize)
	JumpButton.Position = isSmallScreen and UDim2.new(1, jumpButtonSize * -2.25, 1, -jumpButtonSize - 20) or
		UDim2.new(1, jumpButtonSize * -2.75, 1, -jumpButtonSize - 120)

	local touchObject = nil
	JumpButton.InputBegan:connect(function(inputObject)
		if touchObject or inputObject.UserInputType ~= Enum.UserInputType.Touch then
			return
		end

		touchObject = inputObject
		JumpButton.ImageRectOffset = Vector2.new(0, 222)
		if MasterControl then
			MasterControl(true)
		end
	end)

	OnInputEnded = function()
		touchObject = nil
		if MasterControl then
			MasterControl(false)
		end
		JumpButton.ImageRectOffset = Vector2.new(176, 222)
	end

	JumpButton.InputEnded:connect(function(inputObject)
		if inputObject == touchObject then
			OnInputEnded()
		end
	end)

	JumpButton.Parent = parentFrame
	return function(func)
		MasterControl = func
	end
end

return TouchJump


Response:
r = game:service("RunService")

shaft = script.Parent
position = shaft.Position

script.Parent.Explosion.PlayOnRemove = true -- play explosion sound when projectile removed from game

function fly()
	direction = shaft.CFrame.lookVector
	position = position + direction * 5
	error = position - shaft.Position
	shaft.Velocity = 7*error
end

function blow()
	swoosh:stop()
	explosion = Instance.new("Explosion")
	explosion.BlastRadius = 12
	explosion.BlastPressure = 1000000 -- these are really wussy units
	explosion.Position = shaft.Position

	-- find instigator tag
	local creator = script.Parent:findFirstChild("creator")
	if creator ~= nil then
		explosion.Hit:connect(function(part, distance)  onPlayerBlownUp(part, distance, creator) end)
	end

	explosion.Parent = game.Workspace
	connection:disconnect()
	wait(.1)
	shaft:remove()
end

function onPlayerBlownUp(part, distance, creator)

	if part.Name == "Head" then

		local humanoid = part.Parent.Humanoid
		tagHumanoid(humanoid, creator)
	end
end

function tagHumanoid(humanoid, creator)
	-- tag does not need to expire iff all explosions lethal

	if creator ~= nil then
		local new_tag = creator:clone()
		new_tag.Parent = humanoid

	end
end

function untagHumanoid(humanoid)
	if humanoid ~= nil then
		local tag = humanoid:findFirstChild("creator")
		if tag ~= nil then

			tag.Parent = nil
		end
	end
end

t, s = r.Stepped:wait()

swoosh = script.Parent.Swoosh
swoosh:play()

d = t + 10.0 - s
connection = shaft.Touched:connect(blow)

while t < d do
	fly()
	t = r.Stepped:wait()
end


Prompt: -- Requires

Response: local PartUtility = require(ReplicatedStorage.Common.PartUtility)


Prompt:
--[[
	Creates a new promise that receives the result of this promise.

	The given callbacks are invoked depending on that result.
]]

Response:
function Promise:andThen(successHandler, failureHandler)
	-- Even if we haven't specified a failure handler, the rejection will be automatically
	-- passed on by the advancer; other promises in the chain may have unhandled rejections,
	-- but this one is taken care of as soon as any andThen is connected
	self._unhandledRejection = false

	-- Create a new promise to follow this part of the chain
	return Promise.new(function(resolve, reject)
		-- Our default callbacks just pass values onto the next promise.
		-- This lets success and failure cascade correctly!

		local successCallback = resolve
		if successHandler then
			successCallback = createAdvancer(successHandler, resolve, reject)
		end

		local failureCallback = reject
		if failureHandler then
			failureCallback = createAdvancer(failureHandler, resolve, reject)
		end

		if self._status == Promise.Status.Started then
			-- If we haven't resolved yet, put ourselves into the queue
			table.insert(self._queuedResolve, successCallback)
			table.insert(self._queuedReject, failureCallback)
		elseif self._status == Promise.Status.Resolved then
			-- This promise has already resolved! Trigger success immediately.
			successCallback(unpack(self._value))
		elseif self._status == Promise.Status.Rejected then
			-- This promise died a terrible death! Trigger failure immediately.
			failureCallback(unpack(self._value))
		end
	end)
end


Prompt: -- This screenGui exists so that the billboardGui is not deleted when the PlayerGui is reset.

Response:
local BubbleChatScreenGui = Instance.new("ScreenGui")
BubbleChatScreenGui.Name = "BubbleChat"
BubbleChatScreenGui.ResetOnSpawn = false
BubbleChatScreenGui.Parent = PlayerGui

local testLabel = Instance.new("TextLabel")
testLabel.Selectable = false
testLabel.TextWrapped = true
testLabel.Position = UDim2.new(1, 0, 1, 0)
testLabel.Parent = BubbleChatScreenGui

local TextSizeCache = {}


Prompt: --Script

Response:
feedbackMain.CharactersLeft.Text = maxCharacters - #feedbackMain.InputBox.Input.Text
feedbackMain.InputBox.Input.Changed:Connect(function()
	feedbackMain.CharactersLeft.Text = maxCharacters - #feedbackMain.InputBox.Input.Text
	if maxCharacters - #feedbackMain.InputBox.Input.Text < 0 then
		feedbackMain.CharactersLeft.TextColor3 = Color3.fromRGB(255,50,50)
		feedbackMain.SendButton.Style = Enum.ButtonStyle.RobloxRoundButton
	else
		feedbackMain.CharactersLeft.TextColor3 = Color3.fromRGB(255,255,255)
		feedbackMain.SendButton.Style = Enum.ButtonStyle.RobloxRoundDefaultButton
	end
end)

local db = false
feedbackMain.SendButton.MouseButton1Click:Connect(function()
	if not db and maxCharacters - #feedbackMain.InputBox.Input.Text >= 0 then
		db = true
		local msg = feedbackMain.InputBox.Input.Text
		if msg == "Type feedback/bug report here" then
			db = false
			return
		end
		feedbackMain.InputBox.Input.Text = "Sending Message..."
		local response = game.ReplicatedStorage.FilteringFunction:InvokeServer(msg)
		feedbackMain.InputBox.Input.Text = response
		wait(5)
		if feedbackMain.InputBox.Input.Text == response then
			feedbackMain.InputBox.Input.Text = "Type feedback/bug report here"
		end
		db = false
	end
end)

script.Parent.Button.MouseButton1Click:Connect(function()
	open = not open
	if open then
		feedbackMain:TweenPosition(UDim2.new(0.477, 0, 0.438, 0),"Out","Quint",0.3,true)
	else
		feedbackMain:TweenPosition(UDim2.new(1,100,1,-300),"Out","Quint",0.3,true)
	end
end)


Prompt: -- This is were the magic happens!

Response:
function splitbyte(input)
	local byte,p,flags = string.byte(input),128,{false,false,false,false,false,false,false,false}
	for i=1,8 do
		if byte>=p then flags[i],byte = true,byte-p end
		p=p/2
	end
	return flags
end
function formbyte(...)
	local byte = 0
	for p=1,8 do
		local bit=select(p,...)
		if bit then byte=byte+2^(8-p) end
	end
	return string.char(byte)
end
local valueType = "f"
function deflate(forceType,...)
	return string.pack(string.rep(forceType or valueType,#{...}),...)
end
function flate(forceType,raw,n)
	return string.unpack(string.rep(forceType or valueType,n),raw)
end

function getNativeSize(forceType)
	return #string.pack(forceType or valueType ,1)
end


Prompt: --[[Weight and CG]]

Response:
Tune.Weight			= 3000		-- Total weight (in pounds)
Tune.WeightBSize	= {			-- Size of weight brick (dimmensions in studs ; larger = more stable)
	--[[Width]]		6		,
	--[[Height]]		3.5		,
	--[[Length]]		14		}
Tune.WeightDist		= 50		-- Weight distribution (0 - on rear wheels, 100 - on front wheels, can be <0 or >100)
Tune.CGHeight		= .8		-- Center of gravity height (studs relative to median of all wheels)
Tune.WBVisible		= false		-- Makes the weight brick visible


Prompt:
--[[
	Change is used to generate special prop keys that can be used to connect to
	GetPropertyChangedSignal.

	Generally, Change is indexed by a Roblox property name:

		Roact.createElement("TextBox", {
			[Roact.Change.Text] = function(rbx)
				print("The TextBox", rbx, "changed text to", rbx.Text)
			end,
		})
]]

Response:
local Type = require(script.Parent.Parent["Type.roblox"])

local Change = {}

local changeMetatable = {
	__tostring = function(self)
		return string.format("RoactHostChangeEvent(%s)", self.name)
	end,
}

setmetatable(Change, {
	__index = function(self, propertyName)
		local changeListener = {
			[Type] = Type.HostChangeEvent,
			name = propertyName,
		}

		setmetatable(changeListener, changeMetatable)
		Change[propertyName] = changeListener

		return changeListener
	end,
})

return Change


Prompt: --//Setup//--

Response:
local CutsceneGui = script.Parent
CutsceneGui.Enabled = true

local Camera = game.Workspace.CurrentCamera


Prompt: -- Services

Response:
local ReplicateStorage = game:GetService("ReplicatedStorage")
local PlayersService = game:GetService("Players")


Prompt: -- Requires

Response: local GameManager = require(ReplicatedStorage.Common.GameManager)


Prompt: --- Handles user input when the box is focused

Response:
function Window:BeginInput(input, gameProcessed)
	if GuiService.MenuIsOpen then
		self:Hide()
	end

	if gameProcessed and not self:IsVisible() then
		return
	end

	if self.Cmdr.ActivationKeys[input.KeyCode] then -- Activate the command bar
		if self.Cmdr.MashToEnable and not self.Cmdr.Enabled then
			if tick() - lastPressTime < 1 then
				if pressCount >= 5 then
					return self.Cmdr:SetEnabled(true)
				else
					pressCount = pressCount + 1
				end
			else
				pressCount = 1
			end
			lastPressTime = tick()
		elseif self.Cmdr.Enabled then
			self:SetVisible(not self:IsVisible())
			wait()
			self:SetEntryText("")

			if GuiService.MenuIsOpen then -- Special case for menu getting stuck open (roblox bug)
				self:Hide()
			end
		end

		return
	end

	if self.Cmdr.Enabled == false or not self:IsVisible() then
		if self:IsVisible() then
			self:Hide()
		end

		return
	end

	if self.Cmdr.HideOnLostFocus and table.find(MOUSE_TOUCH_ENUM, input.UserInputType) then
		local ps = input.Position
		local ap = Gui.AbsolutePosition
		local as = Gui.AbsoluteSize
		if ps.X < ap.X or ps.X > ap.X + as.X or ps.Y < ap.Y or ps.Y > ap.Y + as.Y then
			self:Hide()
		end
	elseif input.KeyCode == Enum.KeyCode.Down then -- Auto Complete Down
		self:SelectVertical(1)
	elseif input.KeyCode == Enum.KeyCode.Up then -- Auto Complete Up
		self:SelectVertical(-1)
	elseif input.KeyCode == Enum.KeyCode.Return then -- Eat new lines
		task.wait()
		self:SetEntryText(string.gsub(string.gsub(self:GetEntryText(), '\n', ''), '\r', ''))
	elseif input.KeyCode == Enum.KeyCode.Tab then -- Auto complete
		local item = self.AutoComplete:GetSelectedItem()
		local text = self:GetEntryText()
		if item and not (text:sub(#text, #text):match("%s") and self.AutoComplete.LastItem) then
			local replace = item[2]
			local newText
			local insertSpace = true
			local command = self.AutoComplete.Command

			if command then
				local lastArg = self.AutoComplete.Arg

				newText = command.Alias
				insertSpace = self.AutoComplete.NumArgs ~= #command.ArgumentDefinitions
					and self.AutoComplete.IsPartial == false

				local args = command.Arguments
				for i = 1, #args do
					local arg = args[i]
					local segments = arg.RawSegments
					if arg == lastArg then
						segments[#segments] = replace
					end

					local argText = arg.Prefix .. table.concat(segments, ",")

					-- Put auto completion options in quotation marks if they have a space
					if argText:find(" ") or argText == "" then
						argText = ("%q"):format(argText)
					end

					newText = ("%s %s"):format(newText, argText)

					if arg == lastArg then
						break
					end
				end
			else
				newText = replace
			end
			-- need to wait a frame so we can eat the \t
			wait()
			-- Update the text box
			self:SetEntryText(newText .. (insertSpace and " " or ""))
		else
			-- Still need to eat the \t even if there is no auto-complete to show
			wait()
			self:SetEntryText(self:GetEntryText())
		end
	else
		self:ClearHistoryState()
	end
end


Prompt: ---Controller

Response:
local Controller=false
local UserInputService = game:GetService("UserInputService")
local LStickX = 0
local RStickX = 0
local RStickY = 0
local RTriggerValue = 0
local LTriggerValue = 0

local ButtonX = 0
local ButtonY = 0
local ButtonL1 = 0
local ButtonR1 = 0
local ButtonR3 = 0
local DPadUp = 0
function DealWithInput(input,IsRobloxFunction)
	if Controller then
		if input.KeyCode ==Enum.KeyCode.ButtonX then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonX=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonX=0
			end
		elseif input.KeyCode ==Enum.KeyCode.ButtonY then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonY=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonY=0
			end
		elseif input.KeyCode ==Enum.KeyCode.ButtonL1 then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonL1=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonL1=0
			end
		elseif input.KeyCode ==Enum.KeyCode.ButtonR1 then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonR1=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonR1=0
			end
		elseif input.KeyCode ==Enum.KeyCode.DPadLeft then
			if input.UserInputState == Enum.UserInputState.Begin then
				DPadUp=1
			elseif input.UserInputState == Enum.UserInputState.End then
				DPadUp=0
			end
		elseif input.KeyCode ==Enum.KeyCode.ButtonR3 then
			if input.UserInputState == Enum.UserInputState.Begin then
				ButtonR3=1
			elseif input.UserInputState == Enum.UserInputState.End then
				ButtonR3=0
			end
		end
		if input.UserInputType.Name:find("Gamepad") then --it's one of 4 gamepads
			if input.KeyCode == Enum.KeyCode.Thumbstick1 then
				LStickX = input.Position.X
			elseif input.KeyCode == Enum.KeyCode.Thumbstick2 then
				RStickX = input.Position.X
				RStickY = input.Position.Y
			elseif input.KeyCode == Enum.KeyCode.ButtonR2 then--right shoulder
				RTriggerValue = input.Position.Z
			elseif input.KeyCode == Enum.KeyCode.ButtonL2 then--left shoulder
				LTriggerValue = input.Position.Z
			end
		end
	end
end
UserInputService.InputBegan:connect(DealWithInput)
UserInputService.InputChanged:connect(DealWithInput)--keyboards don't activate with Changed, only Begin and Ended. idk if digital controller buttons do too
UserInputService.InputEnded:connect(DealWithInput)

car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name=="SeatWeld" then
		for i,v in pairs(Binded) do
			run:UnbindFromRenderStep(v)
		end
		workspace.CurrentCamera.CameraType=Enum.CameraType.Custom
		workspace.CurrentCamera.FieldOfView=70
		player.CameraMaxZoomDistance=200
	end
end)

function Camera()
	local cam=workspace.CurrentCamera
	local intcam=false
	local CRot=0
	local CBack=0
	local CUp=0
	local mode=0
	local look=0
	local camChange = 0
	local function CamUpdate()
		if not pcall (function()
			if camChange==0 and DPadUp==1 then
				intcam = not intcam
			end
			camChange=DPadUp
			if mode==1 then
				if math.abs(RStickX)>.1 then
					local sPos=1
					if RStickX<0 then sPos=-1 end
					if intcam then
						CRot=sPos*math.abs(((math.abs(RStickX)-.1)/(.9)))*-80
					else
						CRot=sPos*math.abs(((math.abs(RStickX)-.1)/(.9)))*-90
					end
				else
					CRot=0
				end
				if math.abs(RStickY)>.1 then
					local sPos=1
					if RStickY<0 then sPos=-1 end
					if intcam then
						CUp=sPos*math.abs(((math.abs(RStickY)-.1)/(.9)))*30
					else
						CUp=math.min(sPos*math.abs(((math.abs(RStickY)-.1)/(.9)))*-75,30)
					end
				else
					CUp=0
				end
			else
				if CRot>look then
					CRot=math.max(look,CRot-20)
				elseif CRot<look then
					CRot=math.min(look,CRot+20)
				end
				CUp=0
			end
			if intcam then
				CBack=0
			else
				CBack=-180*ButtonR3
			end
			if intcam then
				cam.CameraSubject=player.Character.Humanoid
				cam.CameraType=Enum.CameraType.Scriptable
				cam.FieldOfView=70 + car.DriveSeat.Velocity.Magnitude/40
				player.CameraMaxZoomDistance=5
				local cf=car.Body.Cam.CFrame
				if ButtonR3==1 then
					cf=car.Body.RCam.CFrame
				end
				cam.CoordinateFrame=cf*CFrame.Angles(0,math.rad(CRot+CBack),0)*CFrame.Angles(math.rad(CUp),0,0)
			else
				cam.CameraSubject=car.DriveSeat
				cam.FieldOfView=70
				if mode==0 then
					cam.CameraType=Enum.CameraType.Custom
					player.CameraMaxZoomDistance=400
					run:UnbindFromRenderStep("CamUpdate")
				else
					cam.CameraType = "Scriptable"
					local pspeed = math.min(1,car.DriveSeat.Velocity.Magnitude/500)
					local cc = car.DriveSeat.Position+Vector3.new(0,8+(pspeed*2),0)-((car.DriveSeat.CFrame*CFrame.Angles(math.rad(CUp),math.rad(CRot+CBack),0)).lookVector*17)+(car.DriveSeat.Velocity.Unit*-7*pspeed)
					cam.CoordinateFrame = CFrame.new(cc,car.DriveSeat.Position)
				end
			end
		end) then
			cam.FieldOfView=70
			cam.CameraSubject=player.Character.Humanoid
			cam.CameraType=Enum.CameraType.Custom
			player.CameraMaxZoomDistance=400
			run:UnbindFromRenderStep("CamUpdate")
		end
	end
	local function ModeChange()
		if GMode~=mode then
			mode=GMode
			run:BindToRenderStep("CamUpdate",Enum.RenderPriority.Camera.Value,CamUpdate)
		end
	end
	mouse.KeyDown:connect(function(key)
		if key=="v" then
			run:UnbindFromRenderStep("CamUpdate")
			intcam=not intcam
			run:BindToRenderStep("CamUpdate",Enum.RenderPriority.Camera.Value,CamUpdate)
		end
	end)
	mouse.KeyUp:connect(function(key)
		if key=="z" and look==50 then
			look=0
		elseif key=="x" and (look==-160 or look==-180) then
			look=0
		elseif key=="c" and look==-50 then
			look=0
		end
	end)
	run:BindToRenderStep("CMChange",Enum.RenderPriority.Camera.Value,ModeChange)
	table.insert(Binded,"CamUpdate")
	table.insert(Binded,"CMChange")
end
Camera()

mouse.KeyDown:connect(function(key)
	if key=="b" then
		if GMode>=1 then
			GMode=0
		else
			GMode=GMode+1
		end
		if GMode==1 then
			Controller=true
		else
			Controller=false
		end
	end
end)


Prompt: -- Matches objects to their tree node representation.

Response:
local NodeLookup = {}

local nodeWidth = 0

local QuickButtons = {}

function filteringWorkspace()
	if explorerFilter.Text ~= "" and explorerFilter.Text ~= "Filter workspace..." then
		return true
	end
	return false
end

function lookForAName(obj,name)
	for i,v in pairs(obj:GetChildren()) do
		if string.find(string.lower(v.Name),string.lower(name)) then nameScanned = true end
		lookForAName(v,name)
	end
end

function scanName(obj)
	nameScanned = false
	if string.find(string.lower(obj.Name),string.lower(explorerFilter.Text)) then
		nameScanned = true
	else
		lookForAName(obj,explorerFilter.Text)
	end
	return nameScanned
end

function updateActions()
	for i,v in pairs(QuickButtons) do
		if v.Cond() then
			v.Toggle(true)
		else
			v.Toggle(false)
		end
	end
end

local updateList,rawUpdateList,updateScroll,rawUpdateSize do
	local function r(t)
		for i = 1,#t do
			if not filteringWorkspace() or scanName(t[i].Object) then
				if t.Object == game then
					if childrenGame[t[i].Object] then
						TreeList[#TreeList+1] = t[i]

						local w = (t[i].Depth)*(2+ENTRY_PADDING+GUI_SIZE) + 2 + ENTRY_SIZE + 4 + getTextWidth(t[i].Object.Name) + 4
						if w > nodeWidth then
							nodeWidth = w
						end
						if t[i].Expanded or filteringWorkspace() then
							r(t[i])
						end
					end
				else
					TreeList[#TreeList+1] = t[i]

					local w = (t[i].Depth)*(2+ENTRY_PADDING+GUI_SIZE) + 2 + ENTRY_SIZE + 4 + getTextWidth(t[i].Object.Name) + 4
					if w > nodeWidth then
						nodeWidth = w
					end
					if t[i].Expanded or filteringWorkspace() then
						r(t[i])
					end
				end
			end
		end
	end

	function rawUpdateSize()
		scrollBarH.TotalSpace = nodeWidth
		scrollBarH.VisibleSpace = listFrame.AbsoluteSize.x
		scrollBarH:Update()
		local visible = scrollBarH:CanScrollDown() or scrollBarH:CanScrollUp()
		scrollBarH.GUI.Visible = visible

		listFrame.Size = UDim2_new(1,-GUI_SIZE,1,-GUI_SIZE*(visible and 1 or 0) - HEADER_SIZE)

		scrollBar.VisibleSpace = math.ceil(listFrame.AbsoluteSize.y/ENTRY_BOUND)
		scrollBar.GUI.Size = UDim2_new(0,GUI_SIZE,1,-GUI_SIZE*(visible and 1 or 0) - HEADER_SIZE)

		scrollBar.TotalSpace = #TreeList+1
		scrollBar:Update()
	end

	function rawUpdateList()
		-- Clear then repopulate the entire list. It appears to be fast enough.
		TreeList = {}
		nodeWidth = 0
		r(NodeLookup[game])
		r(NodeLookup[DexOutput])
		r(NodeLookup[HiddenEntries])
		r(NodeLookup[HiddenGame])
		rawUpdateSize()
		updateActions()
	end

	-- Adding or removing large models will cause many updates to occur. We
	-- can reduce the number of updates by creating a delay, then dropping any
	-- updates that occur during the delay.
	local updatingList = false
	function updateList()
		if updatingList then return end
		updatingList = true
		wait(0.25)
		updatingList = false
		rawUpdateList()
	end

	local updatingScroll = false
	function updateScroll()
		if updatingScroll then return end
		updatingScroll = true
		wait(0.25)
		updatingScroll = false
		scrollBar:Update()
	end
end

local Selection do
	local bindGetSelection = explorerPanel:FindFirstChild("GetSelection")
	if not bindGetSelection then
		bindGetSelection = Create('BindableFunction',{Name = "GetSelection"})
		bindGetSelection.Parent = explorerPanel
	end

	local bindSetSelection = explorerPanel:FindFirstChild("SetSelection")
	if not bindSetSelection then
		bindSetSelection = Create('BindableFunction',{Name = "SetSelection"})
		bindSetSelection.Parent = explorerPanel
	end

	local bindSelectionChanged = explorerPanel:FindFirstChild("SelectionChanged")
	if not bindSelectionChanged then
		bindSelectionChanged = Create('BindableEvent',{Name = "SelectionChanged"})
		bindSelectionChanged.Parent = explorerPanel
	end

	local SelectionList = {}
	local SelectionSet = {}
	local Updates = true
	Selection = {
		Selected = SelectionSet;
		List = SelectionList;
	}

	local function addObject(object)
		-- list update
		local lupdate = false
		-- scroll update
		local supdate = false

		if not SelectionSet[object] then
			local node = NodeLookup[object]
			if node then
				table.insert(SelectionList,object)
				SelectionSet[object] = true
				node.Selected = true

				-- expand all ancestors so that selected node becomes visible
				node = node.Parent
				while node do
					if not node.Expanded then
						node.Expanded = true
						lupdate = true
					end
					node = node.Parent
				end
				supdate = true
			end
		end
		return lupdate,supdate
	end

	Selection.Finding = false
	Selection.Found = {}

	function Selection:Set(objects)
		if Selection.Finding then
			Selection.Found = objects
		end

		local lupdate = false
		local supdate = false

		if #SelectionList > 0 then
			for i = 1,#SelectionList do
				local object = SelectionList[i]
				local node = NodeLookup[object]
				if node then
					node.Selected = false
					SelectionSet[object] = nil
				end
			end

			SelectionList = {}
			Selection.List = SelectionList
			supdate = true
		end

		for i = 1,#objects do
			local l,s = addObject(objects[i])
			lupdate = l or lupdate
			supdate = s or supdate
		end

		if lupdate then
			rawUpdateList()
			supdate = true
		elseif supdate then
			scrollBar:Update()
		end

		if supdate then
			bindSelectionChanged:Fire()
			updateActions()
		end
	end

	function Selection:Add(object)
		local l,s = addObject(object)
		if l then
			rawUpdateList()
			if Updates then
				bindSelectionChanged:Fire()
				updateActions()
			end
		elseif s then
			scrollBar:Update()
			if Updates then
				bindSelectionChanged:Fire()
				updateActions()
			end
		end
	end

	function Selection:StopUpdates()
		Updates = false
	end

	function Selection:ResumeUpdates()
		Updates = true
		bindSelectionChanged:Fire()
		updateActions()
	end

	function Selection:Remove(object,noupdate)
		if SelectionSet[object] then
			local node = NodeLookup[object]
			if node then
				node.Selected = false
				SelectionSet[object] = nil
				for i = 1,#SelectionList do
					if SelectionList[i] == object then
						table.remove(SelectionList,i)
						break
					end
				end

				if not noupdate then
					scrollBar:Update()
				end
				bindSelectionChanged:Fire()
				updateActions()
			end
		end
	end

	function Selection:Get()
		local list = {}
		for i = 1,#SelectionList do
			if SelectionList[i] ~= HiddenEntriesMain and SelectionList[i] ~= DexOutputMain then
				table.insert(list, SelectionList[i])
			end
		end
		return list
	end

	bindSetSelection.OnInvoke = function(...)
		Selection:Set(...)
	end

	bindGetSelection.OnInvoke = function()
		return Selection:Get()
	end
end

function CreateCaution(title,msg)
	local newCaution = CautionWindow
	newCaution.Visible = true
	newCaution.Title.Text = title
	newCaution.MainWindow.Desc.Text = msg
	newCaution.MainWindow.Ok.MouseButton1Up:connect(function()
		newCaution.Visible = false
	end)
end

function CreateTableCaution(title,msg)
	if type(msg) ~= "table" then return CreateCaution(title,tostring(msg)) end
	local newCaution = TableCautionWindow:Clone()
	newCaution.Title.Text = title

	local TableList = newCaution.MainWindow.TableResults
	local TableTemplate = newCaution.MainWindow.TableTemplate

	for i,v in pairs(msg) do
		local newResult = TableTemplate:Clone()
		newResult.Type.Text = type(v)
		newResult.Value.Text = tostring(v)
		newResult.Position = UDim2_new(0,0,0,#TableList:GetChildren() * 20)
		newResult.Parent = TableList
		TableList.CanvasSize = UDim2_new(0,0,0,#TableList:GetChildren() * 20)
		newResult.Visible = true
	end
	newCaution.Parent = explorerPanel.Parent
	newCaution.Visible = true
	newCaution.MainWindow.Ok.MouseButton1Up:connect(function()
		newCaution:Destroy()
	end)
end

local function Split(str, delimiter)
	local start = 1
	local t = {}
	while true do
		local pos = string.find (str, delimiter, start, true)
		if not pos then
			break
		end
		table.insert (t, string.sub (str, start, pos - 1))
		start = pos + string.len (delimiter)
	end
	table.insert (t, string.sub (str, start))
	return t
end

local function ToValue(value,type)
	if type == "Vector2" then
		local list = Split(value,",")
		if #list < 2 then return nil end
		local x = tonumber(list[1]) or 0
		local y = tonumber(list[2]) or 0
		return Vector2_new(x,y)
	elseif type == "Vector3" then
		local list = Split(value,",")
		if #list < 3 then return nil end
		local x = tonumber(list[1]) or 0
		local y = tonumber(list[2]) or 0
		local z = tonumber(list[3]) or 0
		return Vector3_new(x,y,z)
	elseif type == "Color3" then
		local list = Split(value,",")
		if #list < 3 then return nil end
		local r = tonumber(list[1]) or 0
		local g = tonumber(list[2]) or 0
		local b = tonumber(list[3]) or 0
		return Color3_new(r/255,g/255, b/255)
	elseif type == "UDim2" then
		local list = Split(string.gsub(string.gsub(value, "{", ""),"}",""),",")
		if #list < 4 then return nil end
		local xScale = tonumber(list[1]) or 0
		local xOffset = tonumber(list[2]) or 0
		local yScale = tonumber(list[3]) or 0
		local yOffset = tonumber(list[4]) or 0
		return UDim2_new(xScale, xOffset, yScale, yOffset)
	elseif type == "Number" then
		return tonumber(value)
	elseif type == "String" then
		return value
	elseif type == "NumberRange" then
		local list = Split(value,",")
		if #list == 1 then
			if tonumber(list[1]) == nil then return nil end
			local newVal = tonumber(list[1]) or 0
			return NumberRange.new(newVal)
		end
		if #list < 2 then return nil end
		local x = tonumber(list[1]) or 0
		local y = tonumber(list[2]) or 0
		return NumberRange.new(x,y)
	elseif type == "Script" then
		local success,err = pcall(function()
			--return loadstring("return "..tostring(value), "?")()
		end)
		if err then
			return nil
		end
	else
		return nil
	end
end

local function ToPropValue(value,type)
	if type == "Vector2" then
		local list = Split(value,",")
		if #list < 2 then return nil end
		local x = tonumber(list[1]) or 0
		local y = tonumber(list[2]) or 0
		return Vector2_new(x,y)
	elseif type == "Vector3" then
		local list = Split(value,",")
		if #list < 3 then return nil end
		local x = tonumber(list[1]) or 0
		local y = tonumber(list[2]) or 0
		local z = tonumber(list[3]) or 0
		return Vector3_new(x,y,z)
	elseif type == "Color3" then
		local list = Split(value,",")
		if #list < 3 then return nil end
		local r = tonumber(list[1]) or 0
		local g = tonumber(list[2]) or 0
		local b = tonumber(list[3]) or 0
		return Color3_new(r/255,g/255, b/255)
	elseif type == "UDim2" then
		local list = Split(string.gsub(string.gsub(value, "{", ""),"}",""),",")
		if #list < 4 then return nil end
		local xScale = tonumber(list[1]) or 0
		local xOffset = tonumber(list[2]) or 0
		local yScale = tonumber(list[3]) or 0
		local yOffset = tonumber(list[4]) or 0
		return UDim2_new(xScale, xOffset, yScale, yOffset)
	elseif type == "Content" then
		return value
	elseif type == "float" or type == "int" or type == "double" then
		return tonumber(value)
	elseif type == "string" then
		return value
	elseif type == "NumberRange" then
		local list = Split(value,",")
		if #list == 1 then
			if tonumber(list[1]) == nil then return nil end
			local newVal = tonumber(list[1]) or 0
			return NumberRange.new(newVal)
		end
		if #list < 2 then return nil end
		local x = tonumber(list[1]) or 0
		local y = tonumber(list[2]) or 0
		return NumberRange.new(x,y)
	elseif string.sub(value,1,4) == "Enum" then
		local getEnum = value
		while true do
			local x,y = string.find(getEnum,".")
			if y then
				getEnum = string.sub(getEnum,y+1)
			else
				break
			end
		end
		print(getEnum)
		return getEnum
	else
		return nil
	end
end

function PromptCaller(inst)
	if CurrentRemoteWindow then
		CurrentRemoteWindow:Destroy()
		CurrentRemoteWindow = nil
	end
	CurrentRemoteWindow = RemoteWindow:Clone()
	CurrentRemoteWindow.Parent = explorerPanel.Parent
	CurrentRemoteWindow.Visible = true

	local displayValues = false

	local ArgumentList = CurrentRemoteWindow.MainWindow.Arguments
	local ArgumentTemplate = CurrentRemoteWindow.MainWindow.ArgumentTemplate

	if inst:IsA("RemoteEvent") or inst:IsA("BindableEvent") then
		CurrentRemoteWindow.Title.Text = "Fire Event"
		CurrentRemoteWindow.MainWindow.Ok.Text = "Fire"
		CurrentRemoteWindow.MainWindow.DisplayReturned.Visible = false
		CurrentRemoteWindow.MainWindow.Desc2.Visible = false
	end

	if inst:IsA("RemoteEvent") or inst:IsA("RemoteFunction") then
		local newArgument = ArgumentTemplate:Clone()
		newArgument.Parent = ArgumentList
		newArgument.Visible = true
		newArgument.Type.Text = "UserNameToFire"
	end

	local newArgument = ArgumentTemplate:Clone()
	if inst:IsA("RemoteEvent") or inst:IsA("RemoteFunction") then
		newArgument.Position = UDim2_new(0,0,0,20)
		ArgumentList.CanvasSize = UDim2_new(0,0,0,40)
	end
	newArgument.Parent = ArgumentList
	newArgument.Visible = true
	newArgument.Type.MouseButton1Down:connect(function()
		createDDown(newArgument.Type,function(choice)
			newArgument.Type.Text = choice
		end,"Script","Number","String","Color3","Vector3","Vector2","UDim2","NumberRange")
	end)

	CurrentRemoteWindow.MainWindow.Ok.MouseButton1Up:connect(function()
		if CurrentRemoteWindow and inst.Parent ~= nil then
			local MyArguments = {}
			for i,v in pairs(ArgumentList:GetChildren()) do
				if inst:IsA("RemoteFunction") or inst:IsA("RemoteEvent") and i == 1 then
					local Players = game:GetService("Players")
					if Players:FindFirstChild(v.Value.Text) then
						table.insert(MyArguments,Players[v.Value.Text])
					else
						CreateCaution("Remote Caller","The username defined is not in-game.")
						return
					end
				end
				table.insert(MyArguments,ToValue(v.Value.Text,v.Type.Text))
			end
			if inst:IsA("RemoteFunction") or inst:IsA("RemoteEvent") then
				if displayValues then
					spawn(function()
						local myResults = RemoteEvent:InvokeServer("CallRemote",inst,MyArguments)
						if myResults then
							CreateTableCaution("Remote Caller",myResults)
						else
							CreateCaution("Remote Caller","This remote did not return anything.")
						end
					end)
				else
					spawn(function()
						RemoteEvent:InvokeServer("CallRemote",inst,MyArguments)
					end)
				end
			else
				RemoteEvent:InvokeServer("CallRemote",inst,MyArguments)
			end
			CurrentRemoteWindow:Destroy()
			CurrentRemoteWindow = nil
		end
	end)

	CurrentRemoteWindow.MainWindow.Add.MouseButton1Up:connect(function()
		if CurrentRemoteWindow then
			local newArgument = ArgumentTemplate:Clone()
			newArgument.Position = UDim2_new(0,0,0,#ArgumentList:GetChildren() * 20)
			newArgument.Parent = ArgumentList
			ArgumentList.CanvasSize = UDim2_new(0,0,0,#ArgumentList:GetChildren() * 20)
			newArgument.Visible = true
			newArgument.Type.MouseButton1Down:connect(function()
				createDDown(newArgument.Type,function(choice)
					newArgument.Type.Text = choice
				end,"Script","Number","String","Color3","Vector3","Vector2","UDim2","NumberRange")
			end)
		end
	end)

	CurrentRemoteWindow.MainWindow.Subtract.MouseButton1Up:connect(function()
		if CurrentRemoteWindow then
			if (inst:IsA("RemoteFunction") or inst:IsA("RemoteEvent")) and #ArgumentList:GetChildren() > 2 then
				ArgumentList:GetChildren()[#ArgumentList:GetChildren()]:Destroy()
				ArgumentList.CanvasSize = UDim2_new(0,0,0,#ArgumentList:GetChildren() * 20)
			elseif inst:IsA("RemoteFunction") == false and inst:IsA("RemoteEvent") == false and #ArgumentList:GetChildren() > 1 then
				ArgumentList:GetChildren()[#ArgumentList:GetChildren()]:Destroy()
				ArgumentList.CanvasSize = UDim2_new(0,0,0,#ArgumentList:GetChildren() * 20)
			end
		end
	end)

	CurrentRemoteWindow.MainWindow.Cancel.MouseButton1Up:connect(function()
		if CurrentRemoteWindow then
			CurrentRemoteWindow:Destroy()
			CurrentRemoteWindow = nil
		end
	end)

	CurrentRemoteWindow.MainWindow.DisplayReturned.MouseButton1Up:connect(function()
		if displayValues then
			displayValues = false
			CurrentRemoteWindow.MainWindow.DisplayReturned.enabled.Visible = false
		else
			displayValues = true
			CurrentRemoteWindow.MainWindow.DisplayReturned.enabled.Visible = true
		end
	end)
end

function DestroyRightClick()
	if currentRightClickMenu then
		currentRightClickMenu:Destroy()
		currentRightClickMenu = nil
	end
	if CurrentInsertObjectWindow and CurrentInsertObjectWindow.Visible then
		CurrentInsertObjectWindow.Visible = false
	end
end

function rightClickMenu(sObj)
	local mouse = game:GetService("Players").LocalPlayer:GetMouse()

	currentRightClickMenu = CreateRightClickMenu(
		{"Cut","Copy","Paste Into","Duplicate","Delete",false,"Group","Ungroup","Select Children",false,"Teleport To","Call Function","Call Remote/Bindable",false,"Insert Part","Insert Object",false},
		"",
		false,
		function(option)
			if option == "Cut" then
				if not Option.Modifiable then return end
				clipboard = {}
				RemoteEvent:InvokeServer("ClearClipboard")
				local list = Selection.List
				local cut = {}
				for i = 1,#list do
					local _, obj = pcall(function() return list[i]:Clone() end)
					if obj then
						table.insert(clipboard,obj)
						table.insert(cut,list[i])
						RemoteEvent:InvokeServer("Copy", list[i])
					end
				end
				for i = 1,#cut do
					pcall(delete,cut[i])
				end
				updateActions()
			elseif option == "Copy" then
				if not Option.Modifiable then return end
				clipboard = {}
				RemoteEvent:InvokeServer("ClearClipboard")
				local list = Selection.List
				for i = 1,#list do
					local _, obj = pcall(function() return list[i]:Clone() end)
					if obj then
						table.insert(clipboard,obj)
					end

					RemoteEvent:InvokeServer("Copy", list[i])
				end
				updateActions()
			elseif option == "Paste Into" then
				if not Option.Modifiable then return end
				local parent = Selection.List[1] or workspace
				if not RemoteEvent:InvokeServer("Paste", parent) then
					for i = 1,#clipboard do
						if (clipboard[i]) then
							pcall(function()
								clipboard[i]:Clone().Parent = parent
							end)
						end
					end
				end
			elseif option == "Duplicate" then
				if not Option.Modifiable then return end
				local list = Selection:Get()
				local parent = Selection.List[1].Parent or workspace;
				for i = 1,#list do
					if not RemoteEvent:InvokeServer("Duplicate", list[i], parent) then -- scel was here again hi
						local _, obj = pcall(function() return list[i]:Clone() end)

						if obj then
							obj.Parent = parent;
						end
					end
				end
			elseif option == "Delete" then
				if not Option.Modifiable then return end
				local list = Selection:Get()
				for i = 1,#list do
					pcall(delete,list[i])
				end
				Selection:Set({})
			elseif option == "Group" then
				if not Option.Modifiable then return end
				local parent = Selection.List[1].Parent or workspace
				local newModel = RemoteEvent:InvokeServer("InstanceNew", "Model", {Parent = parent}) or Instance_new("Model")
				local list = Selection:Get()
				newModel.Parent = parent
				for i = 1,#list do
					list[i].Parent = newModel
					RemoteEvent:InvokeServer("SetProperty", list[i], "Parent", newModel)
				end
				Selection:Set({})
			elseif option == "Ungroup" then
				if not Option.Modifiable then return end
				local ungrouped = {}
				local list = Selection:Get()
				for i = 1,#list do
					if list[i]:IsA("Model") then
						for i2,v2 in pairs(list[i]:GetChildren()) do
							v2.Parent = list[i].Parent or workspace
							table.insert(ungrouped,v2)
							RemoteEvent:InvokeServer("SetProperty", v2, "Parent", list[i].Parent or workspace)
						end
						pcall(delete,list[i])
					end
				end
				Selection:Set({})
				if SettingsRemote:Invoke("SelectUngrouped") then
					for i,v in pairs(ungrouped) do
						Selection:Add(v)
					end
				end
			elseif option == "Select Children" then
				if not Option.Modifiable then return end
				local list = Selection:Get()
				Selection:Set({})
				Selection:StopUpdates()
				for i = 1,#list do
					for i2,v2 in pairs(list[i]:GetChildren()) do
						Selection:Add(v2)
					end
				end
				Selection:ResumeUpdates()
			elseif option == "Teleport To" then
				if not Option.Modifiable then return end
				local list = Selection:Get()
				for i = 1,#list do
					if list[i]:IsA("BasePart") then
						pcall(function()
							game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame = list[i].CFrame
						end)
						break
					end
				end
			elseif option == "Insert Part" then
				if not Option.Modifiable then return end
				local insertedParts = {}
				local list = Selection:Get()
				for i = 1,#list do
					pcall(function()
						local props = {}
						props.Parent = list[i]
						props.CFrame = CFrame_new(game:GetService("Players").LocalPlayer.Character.Head.Position) + Vector3_new(0,3,0)

						local newPart = RemoteEvent:InvokeServer("InstanceNew", "Part", props) or Instance_new("Part")
						newPart.Parent = props.Parent;
						newPart.CFrame = props.CFrame;
						table.insert(insertedParts,newPart)
					end)
				end
			elseif option == "Call Remote/Bindable" then
				if not Option.Modifiable then return end
				local list = Selection:Get()
				for i = 1,#list do
					if list[i]:IsA("RemoteFunction") or list[i]:IsA("RemoteEvent") or list[i]:IsA("BindableFunction") or list[i]:IsA("BindableEvent") then
						PromptCaller(list[i])
						break
					end
				end
			end
		end)
	currentRightClickMenu.Parent = explorerPanel.Parent
	currentRightClickMenu.Position = UDim2_new(0,mouse.X,0,mouse.Y)
	if currentRightClickMenu.AbsolutePosition.X + currentRightClickMenu.AbsoluteSize.X > explorerPanel.AbsolutePosition.X + explorerPanel.AbsoluteSize.X then
		currentRightClickMenu.Position = UDim2_new(0, explorerPanel.AbsolutePosition.X + explorerPanel.AbsoluteSize.X - currentRightClickMenu.AbsoluteSize.X, 0, mouse.Y)
	end
end

local function cancelReparentDrag()end
local function cancelSelectDrag()end
do
	local listEntries = {}
	local nameConnLookup = {}

	local mouseDrag = Create('ImageButton',{
		Name = "MouseDrag";
		Position = UDim2_new(-0.25,0,-0.25,0);
		Size = UDim2_new(1.5,0,1.5,0);
		Transparency = 1;
		AutoButtonColor = false;
		Active = true;
		ZIndex = 10;
	})
	local function dragSelect(last,add,button)
		local connDrag
		local conUp

		conDrag = mouseDrag.MouseMoved:connect(function(x,y)
			local pos = Vector2_new(x,y) - listFrame.AbsolutePosition
			local size = listFrame.AbsoluteSize
			if pos.x < 0 or pos.x > size.x or pos.y < 0 or pos.y > size.y then return end

			local i = math.ceil(pos.y/ENTRY_BOUND) + scrollBar.ScrollIndex
			-- Mouse may have made a large step, so interpolate between the
			-- last index and the current.
			for n = i<last and i or last, i>last and i or last do
				local node = TreeList[n]
				if node then
					if add then
						Selection:Add(node.Object)
					else
						Selection:Remove(node.Object)
					end
				end
			end
			last = i
		end)

		function cancelSelectDrag()
			mouseDrag.Parent = nil
			conDrag:disconnect()
			conUp:disconnect()
			function cancelSelectDrag()end
		end

		conUp = mouseDrag[button]:connect(cancelSelectDrag)

		mouseDrag.Parent = GetScreen(listFrame)
	end

	local function dragReparent(object,dragGhost,clickPos,ghostOffset)
		local connDrag
		local conUp
		local conUp2

		local parentIndex = nil
		local dragged = false

		local parentHighlight = Create('Frame',{
			Transparency = 1;
			Visible = false;
			Create('Frame',{
				BorderSizePixel = 0;
				BackgroundColor3 = Color3_new(0,0,0);
				BackgroundTransparency = 0.1;
				Position = UDim2_new(0,0,0,0);
				Size = UDim2_new(1,0,0,1);
			});
			Create('Frame',{
				BorderSizePixel = 0;
				BackgroundColor3 = Color3_new(0,0,0);
				BackgroundTransparency = 0.1;
				Position = UDim2_new(1,0,0,0);
				Size = UDim2_new(0,1,1,0);
			});
			Create('Frame',{
				BorderSizePixel = 0;
				BackgroundColor3 = Color3_new(0,0,0);
				BackgroundTransparency = 0.1;
				Position = UDim2_new(0,0,1,0);
				Size = UDim2_new(1,0,0,1);
			});
			Create('Frame',{
				BorderSizePixel = 0;
				BackgroundColor3 = Color3_new(0,0,0);
				BackgroundTransparency = 0.1;
				Position = UDim2_new(0,0,0,0);
				Size = UDim2_new(0,1,1,0);
			});
		})
		SetZIndex(parentHighlight,9)

		conDrag = mouseDrag.MouseMoved:connect(function(x,y)
			local dragPos = Vector2_new(x,y)
			if dragged then
				local pos = dragPos - listFrame.AbsolutePosition
				local size = listFrame.AbsoluteSize

				parentIndex = nil
				parentHighlight.Visible = false
				if pos.x >= 0 and pos.x <= size.x and pos.y >= 0 and pos.y <= size.y + ENTRY_SIZE*2 then
					local i = math.ceil(pos.y/ENTRY_BOUND-2)
					local node = TreeList[i + scrollBar.ScrollIndex]
					if node and node.Object ~= object and not object:IsAncestorOf(node.Object) then
						parentIndex = i
						local entry = listEntries[i]
						if entry then
							parentHighlight.Visible = true
							parentHighlight.Position = UDim2_new(0,1,0,entry.AbsolutePosition.y-listFrame.AbsolutePosition.y)
							parentHighlight.Size = UDim2_new(0,size.x-4,0,entry.AbsoluteSize.y)
						end
					end
				end

				dragGhost.Position = UDim2_new(0,dragPos.x+ghostOffset.x,0,dragPos.y+ghostOffset.y)
			elseif (clickPos-dragPos).magnitude > 8 then
				dragged = true
				SetZIndex(dragGhost,9)
				dragGhost.IndentFrame.Transparency = 0.25
				dragGhost.IndentFrame.EntryText.TextColor3 = GuiColor.TextSelected
				dragGhost.Position = UDim2_new(0,dragPos.x+ghostOffset.x,0,dragPos.y+ghostOffset.y)
				dragGhost.Parent = GetScreen(listFrame)
				parentHighlight.Parent = listFrame
			end
		end)

		function cancelReparentDrag()
			mouseDrag.Parent = nil
			conDrag:disconnect()
			conUp:disconnect()
			conUp2:disconnect()
			dragGhost:Destroy()
			parentHighlight:Destroy()
			function cancelReparentDrag()end
		end

		local wasSelected = Selection.Selected[object]
		if not wasSelected and Option.Selectable then
			Selection:Set({object})
		end

		conUp = mouseDrag.MouseButton1Up:connect(function()
			cancelReparentDrag()
			if dragged then
				if parentIndex then
					local parentNode = TreeList[parentIndex + scrollBar.ScrollIndex]
					if parentNode then
						parentNode.Expanded = true

						local parentObj = parentNode.Object
						local function parent(a,b)
							a.Parent = b
						end
						if Option.Selectable then
							local list = Selection.List
							for i = 1,#list do
								pcall(parent,list[i],parentObj)
							end
						else
							pcall(parent,object,parentObj)
						end
					end
				end
			else
				-- do selection click
				if wasSelected and Option.Selectable then
					Selection:Set({})
				end
			end
		end)
		conUp2 = mouseDrag.MouseButton2Down:connect(function()
			cancelReparentDrag()
		end)

		mouseDrag.Parent = GetScreen(listFrame)
	end

	local entryTemplate = Create('ImageButton',{
		Name = "Entry";
		Transparency = 1;
		AutoButtonColor = false;
		Position = UDim2_new(0,0,0,0);
		Size = UDim2_new(1,0,0,ENTRY_SIZE);
		Create('Frame',{
			Name = "IndentFrame";
			BackgroundTransparency = 1;
			BackgroundColor3 = GuiColor.Selected;
			BorderColor3 = GuiColor.BorderSelected;
			Position = UDim2_new(0,0,0,0);
			Size = UDim2_new(1,0,1,0);
			Create(Icon('ImageButton',0),{
				Name = "Expand";
				AutoButtonColor = false;
				Position = UDim2_new(0,-GUI_SIZE,0.5,-GUI_SIZE/2);
				Size = UDim2_new(0,GUI_SIZE,0,GUI_SIZE);
			});
			Create(ClassIcon(nil,0),{
				Name = "ExplorerIcon";
				Position = UDim2_new(0,2+ENTRY_PADDING,0.5,-GUI_SIZE/2);
				Size = UDim2_new(0,GUI_SIZE,0,GUI_SIZE);
			});
			Create('TextLabel',{
				Name = "EntryText";
				BackgroundTransparency = 1;
				TextColor3 = GuiColor.Text;
				TextXAlignment = 'Left';
				TextYAlignment = 'Center';
				Font = FONT;
				FontSize = FONT_SIZE;
				Text = "";
				Position = UDim2_new(0,2+ENTRY_SIZE+4,0,0);
				Size = UDim2_new(1,-2,1,0);
			});
		});
	})

	function scrollBar.UpdateCallback(self)
		for i = 1,self.VisibleSpace do
			local node = TreeList[i + self.ScrollIndex]
			if node then
				local entry = listEntries[i]
				if not entry then
					entry = Create(entryTemplate:Clone(),{
						Position = UDim2_new(0,2,0,ENTRY_BOUND*(i-1)+2);
						Size = UDim2_new(0,nodeWidth,0,ENTRY_SIZE);
						ZIndex = listFrame.ZIndex;
					})
					listEntries[i] = entry

					local expand = entry.IndentFrame.Expand
					expand.MouseEnter:connect(function()
						local node = TreeList[i + self.ScrollIndex]
						if #node > 0 then
							if node.Object ~= HiddenEntriesMain then
								if node.Expanded then
									Icon(expand,NODE_EXPANDED_OVER)
								else
									Icon(expand,NODE_COLLAPSED_OVER)
								end
							else
								if node.HiddenExpanded then
									Icon(expand,NODE_EXPANDED_OVER)
								else
									Icon(expand,NODE_COLLAPSED_OVER)
								end
							end
						end
					end)
					expand.MouseLeave:connect(function()
						pcall(function()
							local node = TreeList[i + self.ScrollIndex]
							if node.Object == HiddenEntriesMain then
								if node.HiddenExpanded then
									Icon(expand,NODE_EXPANDED)
								else
									Icon(expand,NODE_COLLAPSED)
								end
								return
							end
							if #node > 0 then
								if node.Expanded then
									Icon(expand,NODE_EXPANDED)
								else
									Icon(expand,NODE_COLLAPSED)
								end
							end
						end)
					end)

					local function radd(o,refresh,parent)
						addObject(o,refresh,parent)
						local s,children = pcall(function() return o:GetChildren() end, o)
						if s then
							for i = 1,#children do
								radd(children[i],refresh,o)
							end
						end
					end

					expand.MouseButton1Down:connect(function()
						local node = TreeList[i + self.ScrollIndex]
						if #node > 0 then
							if node.Object ~= HiddenEntriesMain then
								node.Expanded = not node.Expanded
							else
								if not MuteHiddenItems then
									NodeLookup[HiddenGame] = {
										Object = HiddenGame;
										Parent = nil;
										Index = 0;
										Expanded = true;
									}
								else
									for i,v in pairs(game:GetChildren()) do
										if not childrenGame[v] then
											radd(v, true, HiddenGame)
										end
									end
								end

								MuteHiddenItems = not MuteHiddenItems
								node.HiddenExpanded = not node.HiddenExpanded
							end
							if node.Object == explorerPanel.Parent and node.Expanded then
								CreateCaution("Warning", "Modifying the contents of this Instance could cause erratic or unstable behavior. Proceed with caution.")
							end
							-- use raw update so the list updates instantly
							rawUpdateList()
						end
					end)

					entry.MouseButton1Down:connect(function(x,y)
						local node = TreeList[i + self.ScrollIndex]
						DestroyRightClick()
						if GetAwaitRemote:Invoke() then
							bindSetAwaiting:Fire(node.Object)
							return
						end

						if node.Object == HiddenEntriesMain then
							return
						end

						if not HoldingShift then
							lastSelectedNode = i + self.ScrollIndex
						end

						if HoldingShift and not filteringWorkspace() then
							if lastSelectedNode then
								if i + self.ScrollIndex - lastSelectedNode > 0 then
									Selection:StopUpdates()
									for i2 = 1, i + self.ScrollIndex - lastSelectedNode do
										local newNode = TreeList[lastSelectedNode + i2]
										if newNode then
											Selection:Add(newNode.Object)
										end
									end
									Selection:ResumeUpdates()
								else
									Selection:StopUpdates()
									for i2 = i + self.ScrollIndex - lastSelectedNode, 1 do
										local newNode = TreeList[lastSelectedNode + i2]
										if newNode then
											Selection:Add(newNode.Object)
										end
									end
									Selection:ResumeUpdates()
								end
							end
							return
						end

						if HoldingCtrl then
							if Selection.Selected[node.Object] then
								Selection:Remove(node.Object)
							else
								Selection:Add(node.Object)
							end
							return
						end
						if Option.Modifiable then
							local pos = Vector2_new(x,y)
							dragReparent(node.Object,entry:Clone(),pos,entry.AbsolutePosition-pos)
						elseif Option.Selectable then
							if Selection.Selected[node.Object] then
								Selection:Set({})
							else
								Selection:Set({node.Object})
							end
							dragSelect(i+self.ScrollIndex,true,'MouseButton1Up')
						end
					end)

					local curSelect
					entry.MouseButton2Down:connect(function()
						if not Option.Selectable then return end

						DestroyRightClick()

						curSelect = entry

						local node = TreeList[i + self.ScrollIndex]

						if node.Object == HiddenEntriesMain then
							return
						end

						if GetAwaitRemote:Invoke() then
							bindSetAwaiting:Fire(node.Object)
							return
						end

						if not Selection.Selected[node.Object] then
							Selection:Set({node.Object})
						end
					end)

					entry.MouseButton2Up:connect(function()
						if not Option.Selectable then return end

						local node = TreeList[i + self.ScrollIndex]

						if node.Object == HiddenEntriesMain then
							return
						end

						if checkMouseInGui(curSelect) then
							rightClickMenu(node.Object)
						end
					end)

					entry.Parent = listFrame
				end

				entry.Visible = true

				local object = node.Object

				-- update expand icon
				if node.Object ~= HiddenEntriesMain then
					if #node == 0 then
						entry.IndentFrame.Expand.Visible = false
					elseif node.Expanded then
						Icon(entry.IndentFrame.Expand,NODE_EXPANDED)
						entry.IndentFrame.Expand.Visible = true
					else
						Icon(entry.IndentFrame.Expand,NODE_COLLAPSED)
						entry.IndentFrame.Expand.Visible = true
					end
				else
					if node.HiddenExpanded then
						Icon(entry.IndentFrame.Expand,NODE_EXPANDED)
						entry.IndentFrame.Expand.Visible = true
					else
						Icon(entry.IndentFrame.Expand,NODE_COLLAPSED)
						entry.IndentFrame.Expand.Visible = true
					end
				end

				-- update explorer icon
				if object ~= HiddenEntriesMain then
					entry.IndentFrame.EntryText.Position = UDim2_new(0,2+ENTRY_SIZE+4,0,0);
					entry.IndentFrame.ExplorerIcon.Visible = true
					ClassIcon(entry.IndentFrame.ExplorerIcon,ClassIndex[object.ClassName] or 0)
				else
					entry.IndentFrame.EntryText.Position = UDim2_new(0,0,0,0);
					entry.IndentFrame.ExplorerIcon.Visible = false
				end

				-- update indentation
				local w = (node.Depth)*(2+ENTRY_PADDING+GUI_SIZE)
				entry.IndentFrame.Position = UDim2_new(0,w,0,0)
				entry.IndentFrame.Size = UDim2_new(1,-w,1,0)

				-- update hidden entries name
				NameHiddenEntries()

				-- update name change detection
				if nameConnLookup[entry] then
					nameConnLookup[entry]:disconnect()
				end
				local text = entry.IndentFrame.EntryText
				text.Text = object.Name
				nameConnLookup[entry] = node.Object.Changed:connect(function(p)
					if p == 'Name' then
						text.Text = object.Name
					end
				end)

				-- update selection
				entry.IndentFrame.Transparency = node.Selected and 0 or 1
				text.TextColor3 = GuiColor[node.Selected and 'TextSelected' or 'Text']

				entry.Size = UDim2_new(0,nodeWidth,0,ENTRY_SIZE)
			elseif listEntries[i] then
				listEntries[i].Visible = false
			end
		end
		for i = self.VisibleSpace+1,self.TotalSpace do
			local entry = listEntries[i]
			if entry then
				listEntries[i] = nil
				entry:Destroy()
			end
		end
	end

	function scrollBarH.UpdateCallback(self)
		for i = 1,scrollBar.VisibleSpace do
			local node = TreeList[i + scrollBar.ScrollIndex]
			if node then
				local entry = listEntries[i]
				if entry then
					entry.Position = UDim2_new(0,2 - scrollBarH.ScrollIndex,0,ENTRY_BOUND*(i-1)+2)
				end
			end
		end
	end

	Connect(listFrame.Changed,function(p)
		if p == 'AbsoluteSize' then
			rawUpdateSize()
		end
	end)

	local wheelAmount = 6
	explorerPanel.MouseWheelForward:connect(function()
		if scrollBar.VisibleSpace - 1 > wheelAmount then
			scrollBar:ScrollTo(scrollBar.ScrollIndex - wheelAmount)
		else
			scrollBar:ScrollTo(scrollBar.ScrollIndex - scrollBar.VisibleSpace)
		end
	end)
	explorerPanel.MouseWheelBackward:connect(function()
		if scrollBar.VisibleSpace - 1 > wheelAmount then
			scrollBar:ScrollTo(scrollBar.ScrollIndex + wheelAmount)
		else
			scrollBar:ScrollTo(scrollBar.ScrollIndex + scrollBar.VisibleSpace)
		end
	end)
end


Prompt: -- WorldSize + ScreenSize -> Depth needed

Response:
function ScreenSpace.GetDepthForWidth(screenWidth, worldWidth)
	local aspectRatio = ScreenSpace.AspectRatio()
	local hfactor = math.tan(math.rad(workspace.CurrentCamera.FieldOfView)/2)
	local wfactor = aspectRatio*hfactor
	local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
	--
	return -(sx * worldWidth) / (screenWidth * 2 * wfactor)
end
function ScreenSpace.GetDepthForHeight(screenHeight, worldHeight)
	local hfactor = math.tan(math.rad(workspace.CurrentCamera.FieldOfView)/2)
	local sy = ScreenSpace.ViewSizeY()
	--
	return -(sy * worldHeight) / (screenHeight * 2 * hfactor)
end


Prompt: -- an awkward way to set a zero-indexed table...

Response:
luaP.opmodes[0] =
  opmode(0, 1, "OpArgR", "OpArgN", "iABC")      -- OP_MOVE

return luaP


Prompt: -- ROBLOX TODO: continue to implement prettyFormat plugins

Response:
local prettyFormatPlugins = PrettyFormat.plugins
local PLUGINS = {
	prettyFormatPlugins.AsymmetricMatcher,
	-- ROBLOX deviation: Roblox Instance matchers
	prettyFormatPlugins.RobloxInstance,
}

type MatcherHintColor = (string) -> string -- subset of Chalk type

export type MatcherHintOptions = {
	comment: string?,
	-- ROBLOX TODO? should be MatcherHintColor like in upstream, but requires modeling Chalk differently
	expectedColor: MatcherHintColor?,
	isDirectExpectCall: boolean?,
	isNot: boolean?,
	promise: string?,
	-- ROBLOX TODO? should be MatcherHintColor like in upstream, but requires modeling Chalk differently
	receivedColor: string?,
	secondArgument: string?,
	-- ROBLOX TODO? should be MatcherHintColor like in upstream, but requires modeling Chalk differently
	secondArgumentColor: MatcherHintColor?,
}

export type DiffOptions = ImportDiffOptions

local EXPECTED_COLOR = chalk.green
local RECEIVED_COLOR = chalk.red
local INVERTED_COLOR = chalk.inverse
local BOLD_WEIGHT = chalk.bold
local DIM_COLOR = chalk.dim

local MULTILINE_REGEXP = "\n"
local SPACE_SYMBOL = utf8.char(183) -- middle dot

local NUMBERS = {
	"zero",
	"one",
	"two",
	"three",
	"four",
	"five",
	"six",
	"seven",
	"eight",
	"nine",
	"ten",
	"eleven",
	"twelve",
	"thirteen",
}

local SUGGEST_TO_CONTAIN_EQUAL =
	"Looks like you wanted to test for object/array equality with the stricter `toContain` matcher. You probably need to use `toContainEqual` instead."

local replaceTrailingSpaces, getCommonAndChangedSubstrings, isLineDiffable, shouldPrintDiff, replaceMatchedToAsymmetricMatcher, isAsymmetricMatcher
local matcherErrorMessage, matcherHint

local function stringify(object: any, maxDepth: number?): string
	-- ROBLOX deviation: Added this if logic to deal with handling nil values in Lua tables
	if object == Symbol.for_("$$nil") then
		object = nil
	end
	maxDepth = maxDepth or 10

	local MAX_LENGTH = 10000
	local result

	local ok = pcall(function()
		result = prettyFormat(object, {
			maxDepth = maxDepth,
			min = true,
			plugins = PLUGINS,
		})
	end)

	if not ok then
		result = prettyFormat(object, {
			callToJSON = false,
			maxDepth = maxDepth,
			min = true,
			plugins = PLUGINS,
		})
	end

	if #result >= MAX_LENGTH and maxDepth > 1 then
		--[[
			ROBLOX TODO: Remove the "if maxDepth" check once it can pass through
			Luau cleanly
		]]
		if maxDepth then
			return stringify(object, math.floor(maxDepth / 2))
		end
	end
	return result
end

local function highlightTrailingWhitespace(text: string): string
	return text:gsub("%s+$", function(s)
		return INVERTED_COLOR(s)
	end)
end


Prompt: ---- Locales -----

Response: local Event = game:GetService("ReplicatedStorage").Events.Cases.AdminCase


Prompt:
-- Choose current Touch control module based on settings (user, dev)
-- Returns module (possibly nil) and success code to differentiate returning nil due to error vs Scriptable

Response:
function ControlModule:SelectTouchModule()
	if not UserInputService.TouchEnabled then
		return nil, false
	end
	local touchModule = nil
	local DevMovementMode = Players.LocalPlayer.DevTouchMovementMode
	if DevMovementMode == Enum.DevTouchMovementMode.UserChoice then
		touchModule = movementEnumToModuleMap[UserGameSettings.TouchMovementMode]
	elseif DevMovementMode == Enum.DevTouchMovementMode.Scriptable then
		return nil, true
	else
		touchModule = movementEnumToModuleMap[DevMovementMode]
	end
	return touchModule, true
end

function ControlModule:OnRenderStepped(dt)
	if self.activeController and self.activeController.enabled and self.humanoid then
		local moveVector = self.activeController:GetMoveVector()

		local vehicleConsumedInput = false
		if self.vehicleController then
			moveVector, vehicleConsumedInput = self.vehicleController:Update(moveVector, self.activeControlModule==Gamepad)
		end

		-- User of vehicleConsumedInput is commented out to preserve legacy behavior, in case some game relies on Humanoid.MoveDirection still being set while in a VehicleSeat
		--if not vehicleConsumedInput then
			self.moveFunction(Players.LocalPlayer, moveVector, self.cameraRelative)
		--end

		self.humanoid.Jump = self.activeController:GetIsJumping() or (self.touchJumpController and self.touchJumpController:GetIsJumping())
	end
end

function ControlModule:OnHumanoidSeated(active, currentSeatPart)
	if active then
		if currentSeatPart and currentSeatPart:IsA("VehicleSeat") then
			if not self.vehicleController then
				self.vehicleController = self.vehicleController.new(CONTROL_ACTION_PRIORITY)
			end
			self.vehicleController:Enable(true, currentSeatPart)
		end
	else
		if self.vehicleController then
			self.vehicleController:Enable(false, currentSeatPart)
		end
	end
end

function ControlModule:OnCharacterAdded(char)
	self.humanoid = char:FindFirstChildOfClass("Humanoid")
	while not self.humanoid do
		char.ChildAdded:wait()
		self.humanoid = char:FindFirstChildOfClass("Humanoid")
	end

	if self.humanoidSeatedConn then
		self.humanoidSeatedConn:Disconnect()
		self.humanoidSeatedConn = nil
	end
	self.humanoidSeatedConn = self.humanoid.Seated:Connect(function(active, currentSeatPart) self:OnHumanoidSeated(active, currentSeatPart) end)
end

function ControlModule:OnCharacterRemoving(char)
	self.humanoid = nil
end


Prompt: --	local throtOff = script.Parent.Values.RPM.Value > 7500 and randomability <=1 and script.Parent.Values.Throttle.Value <= _Tune.IdleThrottle/100

Response:
	local redline = script.Parent.Values.Throttle.Value > 0 and math.ceil(script.Parent.Values.RPM.Value) > _Tune.Redline-_Tune.RevBounce and script.Parent.Values.Gear.Value<#_Tune.Ratios-2

	if redline then
		if FE then
			handler:FireServer("Backfire2")
			wait (0.1)
		else
			car.Body.Exhaust.Backfire1.Backfire2:play()
			car.Body.Exhaust.Backfire2.Backfire2:play()
			car.Body.Exhaust.Backfire3.Backfire2:play()
			car.Body.Exhaust.Backfire4.Backfire2:play()
			car.Body.Exhaust.Backfire1.Fire.Enabled = true
			car.Body.Exhaust.Backfire2.Fire.Enabled = true
			car.Body.Exhaust.Backfire3.Fire.Enabled = true
			car.Body.Exhaust.Backfire4.Fire.Enabled = true
			car.Body.Exhaust.BFLight1.SpotLight.Enabled = true
			car.Body.Exhaust.BFLight2.SpotLight.Enabled = true
			car.Body.Exhaust.BFLight3.SpotLight.Enabled = true
			car.Body.Exhaust.BFLight4.SpotLight.Enabled = true
			wait (0.03)
			car.Body.Exhaust.Backfire1.Fire.Enabled = false
			car.Body.Exhaust.Backfire2.Fire.Enabled = false
			car.Body.Exhaust.Backfire3.Fire.Enabled = false
			car.Body.Exhaust.Backfire4.Fire.Enabled = false
			car.Body.Exhaust.BFLight1.SpotLight.Enabled = false
			car.Body.Exhaust.BFLight2.SpotLight.Enabled = false
			car.Body.Exhaust.BFLight3.SpotLight.Enabled = false
			car.Body.Exhaust.BFLight4.SpotLight.Enabled = false
			wait (0.07)
		end
	end