Prompt: -- Event that fires when a new point is snapped

Response:
PointSnapped = Core.RbxUtility.CreateSignal();

function StartSnapping()

	-- Make sure snapping isn't already enabled
	if SnappingStage or SnapTracking.Enabled then
		return;
	end;

	-- Start first snapping stage
	SnappingStage = 'Starting';

	-- Only enable corner snapping
	SnapTracking.TrackEdgeMidpoints = false;
	SnapTracking.TrackFaceCentroids = false;
	SnapTracking.TargetFilter = Selection.IsSelected;

	-- Trigger the PointSnapped event when a new point is snapped
	SnapTracking.StartTracking(function (NewPoint)
		if NewPoint and NewPoint.p ~= SnappedPoint then
			SnappedPoint = NewPoint.p;
			PointSnapped:fire(NewPoint.p);
		end;
	end);

	-- Listen for when the user starts dragging while in snap mode
	Connections.SnapDragStart = Support.AddUserInputListener('Began', 'MouseButton1', false, function (Input)

		-- Initialize snapping state
		SnappingStage = 'Direction';
		SnappingStartAim = Vector2.new(Input.Position.X, Input.Position.Y);
		SnappingStartPoint = SnappedPoint;
		SnappingStartTarget = SnapTracking.Target;
		SnappingStartDirections = GetFaceOffsetsFromCorner(SnappingStartTarget, SnappingStartPoint);
		SnappingStartSelectionState = PreparePartsForResizing();
		AreaPermissions = Security.GetPermissions(Security.GetSelectionAreas(Selection.Items), Core.Player);

		-- Pause snapping
		SnapTracking.StopTracking();

		-- Start a direction line
		DirectionLine = Core.Tool.Interfaces.SnapLine:Clone();
		DirectionLine.Parent = Core.UI;
		DirectionLine.Visible = false;

		-- Track changes for history
		TrackChange();

		-- Listen for when the user drags
		Connections.SnapDrag = Support.AddUserInputListener('Changed', 'MouseMovement', true, function (Input)

			-- Update the latest aim
			SnappingEndAim = Vector2.new(Input.Position.X, Input.Position.Y);
			ScreenSnappedPoint = Workspace.CurrentCamera:WorldToScreenPoint(SnappingStartPoint);
			ScreenSnappedPoint = Vector2.new(ScreenSnappedPoint.X, ScreenSnappedPoint.Y);

			-- Calculate direction setting length
			local DirectionSettingLength = math.min(50, math.max(50, (SnappingStartAim - ScreenSnappedPoint).magnitude * 1.5));

			-- Use the mouse position to figure out the resize direction (until after direction setting length)
			if SnappingStage == 'Direction' then

				-- Get current angle from snap point
				local DragAngle = math.deg(math.atan2(SnappingEndAim.Y - ScreenSnappedPoint.Y, SnappingEndAim.X - ScreenSnappedPoint.X));
				DragAngle = (DragAngle > 0) and (DragAngle - 360) or DragAngle;

				-- Go through corner offsets representing the possible directions
				local Directions = {};
				for _, Direction in pairs(SnappingStartDirections) do

					-- Map the corner & corner offset to screen points
					local ScreenOffsetPoint = Workspace.CurrentCamera:WorldToScreenPoint(Direction.Offset);

					-- Get direction angle from snap point
					local DirectionAngle = math.deg(math.atan2(ScreenOffsetPoint.Y - ScreenSnappedPoint.Y, ScreenOffsetPoint.X - ScreenSnappedPoint.X));
					DirectionAngle = (DirectionAngle > 0) and (DirectionAngle - 360) or DirectionAngle;

					-- Calculate delta between drag and direction angles
					local AngleDelta = math.abs(DragAngle - DirectionAngle) % 180;
					AngleDelta = (AngleDelta > 90) and (180 - AngleDelta) or AngleDelta;

					-- Insert the potential direction
					table.insert(Directions, {
						Face = Direction.Face,
						AngleDelta = AngleDelta,
						DirectionAngle = DirectionAngle,
						Offset = Direction.Offset
					});

				end;

				-- Get the direction most similar to the dragging angle
				table.sort(Directions, function (A, B)
					return A.AngleDelta < B.AngleDelta;
				end);

				-- Center direction line at snap point
				DirectionLine.Position = UDim2.new(0, ScreenSnappedPoint.X, 0, ScreenSnappedPoint.Y);

				-- Orient direction line towards drag direction
				if math.abs(DragAngle - Directions[1].DirectionAngle) <= 90 then
					DirectionLine.Rotation = Directions[1].DirectionAngle;
				else
					DirectionLine.Rotation = 180 + Directions[1].DirectionAngle;
				end;

				-- Show the direction line
				DirectionLine.PointMarker.Rotation = -DirectionLine.Rotation;
				DirectionLine.SnapProgress.Size = UDim2.new(0, DirectionSettingLength, 2, 0);
				DirectionLine.Visible = true;

				-- Check if drag has passed direction setting length
				local Length = (SnappingEndAim - ScreenSnappedPoint).magnitude;
				if Length < DirectionSettingLength then
					return;
				end;

				-- Clear the direction line
				DirectionLine:Destroy()

				-- Select the resizing direction that was closest to the mouse drag
				SnappingDirection = Directions[1].Face;
				SnappingDirectionOffset = Directions[1].Offset;

				-- Move to the destination-picking stage of snapping
				SnappingStage = 'Destination';

				-- Set destination-stage snapping options
				SnapTracking.TrackEdgeMidpoints = true;
				SnapTracking.TrackFaceCentroids = true;
				SnapTracking.TargetFilter = function (Target) return not Target.Locked; end;
				SnapTracking.TargetBlacklist = Selection.Items;

				-- Start a distance alignment line
				AlignmentLine = Core.Tool.Interfaces.SnapLineSegment:Clone();
				AlignmentLine.Visible = false;
				AlignmentLine.Parent = Core.UI;

				-- Re-enable snapping to select destination
				SnapTracking.StartTracking(function (NewPoint)
					if NewPoint and NewPoint.p ~= SnappedPoint then
						SnappedPoint = NewPoint.p;
						PointSnapped:fire(NewPoint.p);
					end;
				end);

			end;

		end);

		-- Listen for when a new point is snapped
		Connections.Snap = PointSnapped:connect(function (SnappedPoint)

			-- Resize to snap point if in the destination stage of snapping
			if SnappingStage == 'Destination' then

				-- Calculate direction and distance to resize towards
				local Direction = (SnappingDirectionOffset - SnappingStartPoint).unit;
				local Distance = (SnappedPoint - SnappingStartPoint):Dot(Direction);

				-- Resize the parts on the selected faces by the calculated distance
				local Success = ResizePartsByFace(SnappingDirection, Distance, 'Normal', SnappingStartSelectionState);

				-- Update the UI on resize success
				if Success then

					-- Update "studs resized" indicator
					if ResizeTool.UI then
						ResizeTool.UI.Changes.Text.Text = 'resized ' .. Support.Round(Distance, 3) .. ' studs';
					end;

					-- Get snap point and destination point screen positions for UI alignment
					local ScreenStartPoint = Workspace.CurrentCamera:WorldToScreenPoint(SnappingStartPoint + (Direction * Distance));
					ScreenStartPoint = Vector2.new(ScreenStartPoint.X, ScreenStartPoint.Y);
					local ScreenDestinationPoint = Workspace.CurrentCamera:WorldToScreenPoint(SnappedPoint);
					ScreenDestinationPoint = Vector2.new(ScreenDestinationPoint.X, ScreenDestinationPoint.Y)

					-- Update the distance alignment line
					local AlignmentAngle = math.deg(math.atan2(ScreenDestinationPoint.Y - ScreenStartPoint.Y, ScreenDestinationPoint.X - ScreenStartPoint.X));
					local AlignmentCenter = ScreenStartPoint:Lerp(ScreenDestinationPoint, 0.5);
					AlignmentLine.Position = UDim2.new(0, AlignmentCenter.X, 0, AlignmentCenter.Y);
					AlignmentLine.Rotation = AlignmentAngle;
					AlignmentLine.Size = UDim2.new(0, (ScreenDestinationPoint - ScreenStartPoint).magnitude, 0, 1);
					AlignmentLine.PointMarkerA.Rotation = -AlignmentAngle;
					AlignmentLine.Visible = true;

				end;

				-- Make sure we're not entering any unauthorized private areas
				if Core.Mode == 'Tool' and Security.ArePartsViolatingAreas(Selection.Items, Core.Player, false, AreaPermissions) then
					for Part, State in pairs(SnappingStartSelectionState) do
						Part.Size = State.Size;
						Part.CFrame = State.CFrame;
					end;
				end;

			end;

		end);

	end);

end;


Prompt: --//Controller//--

Response:
repeat
	task.wait()

	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = CameraPart.CFrame
until

Camera.CameraType == Enum.CameraType.Scriptable

task.wait(5)

TweenService:Create(
	CutsceneFrame,

	TweenInfo.new(
		1
	),

	{
		Transparency = 0
	}
):Play()

task.wait(2)

repeat
	task.wait()

	Camera.CameraType = Enum.CameraType.Custom

	CutsceneGui.CinematicFrame1.Transparency = 1
	CutsceneGui.CinematicFrame2.Transparency = 1

until

Camera.CameraType == Enum.CameraType.Custom

TweenService:Create(
	CutsceneFrame,

	TweenInfo.new(
		1
	),

	{
		Transparency = 1
	}
):Play()

Debris:AddItem(CutsceneGui, 1)


Prompt: --[[Engine]]

Response:
	--Torque Curve
	Tune.Horsepower		= 350		--	[TORQUE CURVE VISUAL]
	Tune.IdleRPM		= 700		--		https://www.desmos.com/calculator/2uo3hqwdhf
	Tune.PeakRPM		= 6000		--		Use sliders to manipulate values
	Tune.Redline		= 6700		--		Copy and paste slider values into the respective tune values
	Tune.EqPoint		= 5500
	Tune.PeakSharpness	= 7.5
	Tune.CurveMult		= 0.16

	--Incline Compensation
	Tune.InclineComp	= 1.7			-- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)

	--Misc
	Tune.RevAccel		= 150		-- RPM acceleration when clutch is off
	Tune.RevDecay		= 75		-- RPM decay when clutch is off
	Tune.RevBounce		= 500		-- RPM kickback from redline
	Tune.IdleThrottle	= 3			-- Percent throttle at idle
	Tune.ClutchTol		= 500		-- Clutch engagement threshold (higher = faster response)


Prompt: -- << SET UP PLAYER DATA >>

Response:
local getLimitPerMin = 6
local getRefreshInterval = 10
local getLimit = getLimitPerMin*(getRefreshInterval/60)
local getRequests = {}
spawn(function()
	while true do
		wait(getRefreshInterval)
		getRequests = {}
	end
end)
function module:GetData(caller, retries, userId)
	if not getRequests[caller] then
		getRequests[caller] = 0
	end
	getRequests[caller] = getRequests[caller] + 1
	if getRequests[caller] <= getLimit then
		local success, data = main:GetModule("DataStores"):GetData(playerDataStore, retries, userId)
		return success, data
	else
		--warn(caller.Name,"exeeded getLimit!")
	end
end

function module:SetupPlayerData(player)

	local dataTemplate = getDataTemplate()
	local success, pdata = self:GetData(player, datastoreRetries, player.UserId)

	--Can't access DataStore
	if not success and not main.isStudio then
		return nil

	--New player
	elseif not pdata then
		pdata = dataTemplate
		savePlayerData(player)
		local welcomeBadgeId = tonumber(main.settings.WelcomeBadgeId)
		if welcomeBadgeId and welcomeBadgeId > 0 then
			main.badgeService:AwardBadge(player.UserId, welcomeBadgeId)
		end

	--Existing player
	else
		for statName, statValue in pairs(dataTemplate) do
			if pdata[statName] == nil then
				pdata[statName] = statValue
			end
			if statName == "DefaultSettings" then
				for i, settingName in pairs(defaultSettingsToAdd) do
					if pdata[statName][settingName] == nil then
						pdata[statName][settingName] = settings[settingName]
					end
				end
			end
		end

	end

	main.pd[player] = pdata
	return pdata
end


Prompt:
--[[
	Constructor for a new CameraModule.

	Parameters:
	- camera (Camera): current camera of the LocalPlayer
]]

Response:
function CameraModule.new(camera, tweenService)
	local self = {
		initialCFrame = nil,
		camera = camera,
		surfaceGui = nil,
		tweenService = tweenService or TweenService,
	}
	setmetatable(self, CameraModule)

	return self
end


Prompt:
--[=[
	@class Component

	Bind components to Roblox instances using the Component class and CollectionService tags.

	To avoid confusion of terms:
	- `Component` refers to this module.
	- `Component Class` (e.g. `MyComponent` through this documentation) refers to a class created via `Component.new`
	- `Component Instance` refers to an instance of a component class.
	- `Roblox Instance` refers to the Roblox instance to which the component instance is bound.

	Methods and properties are tagged with the above terms to help clarify the level at which they are used.
]=]

Response:
local Component = {}
Component.__index = Component


Prompt: --// F key, HornOn

Response:
mouse.KeyDown:connect(function(key)
	if key=="h" then
		veh.Lightbar.middle.Airhorn:Play()
		veh.Lightbar.middle.Wail.Volume = 0
		veh.Lightbar.middle.Yelp.Volume = 0
		veh.Lightbar.middle.Priority.Volume = 0
	end
end)


Prompt: --WeldRec(P.Parent.Lights)

Response:
for _,v in pairs(weldedParts) do
	if v:IsA("BasePart") then
		v.Anchored = false
	end
end

script:Destroy()


Prompt: -- Effect Stop

Response:
	Model.Configuration.Ballywho.Value = 0
	Model.Configuration.ColorRand.Value = 0


Prompt: -- Decompiled with the Synapse X Luau decompiler.

Response:
local v1 = {};

	for v2, v3 in ipairs((game.ReplicatedStorage.Game.Abilities:GetChildren())) do
	if not v2 then
		break;
	end;
	local v5 = v3:FindFirstChildOfClass("ModuleScript");
	if v5 then
		v1[v3.Name] = require(v5);
	end;
end;
return v1;


Prompt: --[[ The Module ]]

Response:
--
local TransparencyController = {}
TransparencyController.__index = TransparencyController

function TransparencyController.new()
	local self = setmetatable({}, TransparencyController)

	self.lastUpdate = tick()
	self.transparencyDirty = false
	self.enabled = false
	self.lastTransparency = nil

	self.descendantAddedConn, self.descendantRemovingConn = nil, nil
	self.toolDescendantAddedConns = {}
	self.toolDescendantRemovingConns = {}
	self.cachedParts = {}

	return self
end

function TransparencyController:HasToolAncestor(object)
	if object.Parent == nil then return false end
	return object.Parent:IsA('Tool') or self:HasToolAncestor(object.Parent)
end

function TransparencyController:IsValidPartToModify(part)
	if part:IsA('BasePart') or part:IsA('Decal') then
		return not self:HasToolAncestor(part)
	end
	return false
end

function TransparencyController:CachePartsRecursive(object)
	if object then
		if self:IsValidPartToModify(object) then
			self.cachedParts[object] = true
			self.transparencyDirty = true
		end
		for _, child in pairs(object:GetChildren()) do
			self:CachePartsRecursive(child)
		end
	end
end

function TransparencyController:TeardownTransparency()
	for child, _ in pairs(self.cachedParts) do
		child.LocalTransparencyModifier = 0
	end
	self.cachedParts = {}
	self.transparencyDirty = true
	self.lastTransparency = nil

	if self.descendantAddedConn then
		self.descendantAddedConn:disconnect()
		self.descendantAddedConn = nil
	end
	if self.descendantRemovingConn then
		self.descendantRemovingConn:disconnect()
		self.descendantRemovingConn = nil
	end
	for object, conn in pairs(self.toolDescendantAddedConns) do
		conn:Disconnect()
		self.toolDescendantAddedConns[object] = nil
	end
	for object, conn in pairs(self.toolDescendantRemovingConns) do
		conn:Disconnect()
		self.toolDescendantRemovingConns[object] = nil
	end
end

function TransparencyController:SetupTransparency(character)
	self:TeardownTransparency()

	if self.descendantAddedConn then self.descendantAddedConn:disconnect() end
	self.descendantAddedConn = character.DescendantAdded:Connect(function(object)
		-- This is a part we want to invisify
		if self:IsValidPartToModify(object) then
			self.cachedParts[object] = true
			self.transparencyDirty = true
		-- There is now a tool under the character
		elseif object:IsA('Tool') then
			if self.toolDescendantAddedConns[object] then self.toolDescendantAddedConns[object]:Disconnect() end
			self.toolDescendantAddedConns[object] = object.DescendantAdded:Connect(function(toolChild)
				self.cachedParts[toolChild] = nil
				if toolChild:IsA('BasePart') or toolChild:IsA('Decal') then
					-- Reset the transparency
					toolChild.LocalTransparencyModifier = 0
				end
			end)
			if self.toolDescendantRemovingConns[object] then self.toolDescendantRemovingConns[object]:disconnect() end
			self.toolDescendantRemovingConns[object] = object.DescendantRemoving:Connect(function(formerToolChild)
				wait() -- wait for new parent
				if character and formerToolChild and formerToolChild:IsDescendantOf(character) then
					if self:IsValidPartToModify(formerToolChild) then
						self.cachedParts[formerToolChild] = true
						self.transparencyDirty = true
					end
				end
			end)
		end
	end)
	if self.descendantRemovingConn then self.descendantRemovingConn:disconnect() end
	self.descendantRemovingConn = character.DescendantRemoving:connect(function(object)
		if self.cachedParts[object] then
			self.cachedParts[object] = nil
			-- Reset the transparency
			object.LocalTransparencyModifier = 0
		end
	end)
	self:CachePartsRecursive(character)
end

function TransparencyController:Enable(enable)
	if self.enabled ~= enable then
		self.enabled = enable
		self:Update()
	end
end

function TransparencyController:SetSubject(subject)
	local character = nil
	if subject and subject:IsA("Humanoid") then
		character = subject.Parent
	end
	if subject and subject:IsA("VehicleSeat") and subject.Occupant then
		character = subject.Occupant.Parent
	end
	if character then
		self:SetupTransparency(character)
	else
		self:TeardownTransparency()
	end
end

function TransparencyController:Update()
	local instant = false
	local now = tick()
	local currentCamera = workspace.CurrentCamera

	if currentCamera then
		local transparency = 0
		if not self.enabled then
			instant = true
		else
			local distance = (currentCamera.Focus.p - currentCamera.CoordinateFrame.p).magnitude
			transparency = (distance<2) and (1.0-(distance-0.5)/1.5) or 0 --(7 - distance) / 5
			if transparency < 0.5 then
				transparency = 0
			end

			if self.lastTransparency then
				local deltaTransparency = transparency - self.lastTransparency

				-- Don't tween transparency if it is instant or your character was fully invisible last frame
				if not instant and transparency < 1 and self.lastTransparency < 0.95 then
					local maxDelta = MAX_TWEEN_RATE * (now - self.lastUpdate)
					deltaTransparency = Util.Clamp(-maxDelta, maxDelta, deltaTransparency)
				end
				transparency = self.lastTransparency + deltaTransparency
			else
				self.transparencyDirty = true
			end

			transparency = Util.Clamp(0, 1, Util.Round(transparency, 2))
		end

		if self.transparencyDirty or self.lastTransparency ~= transparency then
			for child, _ in pairs(self.cachedParts) do
				child.LocalTransparencyModifier = transparency
			end
			self.transparencyDirty = false
			self.lastTransparency = transparency
		end
	end
	self.lastUpdate = now
end

return TransparencyController


Prompt: --LIGHTS BUTTONS

Response:
for _,i in pairs(lights:GetChildren()) do
	if i:IsA("ImageButton") and i.Name ~= "header" then
		if string.match(i.Name,"%l+") == "td" then
			i.MouseButton1Click:connect(function()
				script.Parent.lighty.Value = tonumber(string.match(i.Name,"%d"))
				if script.Parent.lighty.Value == 0 then
					lights.td0.Image = imgassets.offon
					lights.td1.Image = imgassets.hazardoff
					lights.td2.Image = imgassets.leftyoff
					lights.td3.Image = imgassets.rightyoff
					lights.td4.Image = imgassets.outoff
				elseif script.Parent.lighty.Value == 1 then
					lights.td0.Image = imgassets.offoff
					lights.td1.Image = imgassets.hazardon
					lights.td2.Image = imgassets.leftyoff
					lights.td3.Image = imgassets.rightyoff
					lights.td4.Image = imgassets.outoff
				elseif script.Parent.lighty.Value == 2 then
					lights.td0.Image = imgassets.offoff
					lights.td1.Image = imgassets.hazardoff
					lights.td2.Image = imgassets.leftyon
					lights.td3.Image = imgassets.rightyoff
					lights.td4.Image = imgassets.outoff
				elseif script.Parent.lighty.Value == 3 then
					lights.td0.Image = imgassets.offoff
					lights.td1.Image = imgassets.hazardoff
					lights.td2.Image = imgassets.leftyoff
					lights.td3.Image = imgassets.rightyon
					lights.td4.Image = imgassets.outoff
				elseif script.Parent.lighty.Value == 4 then
					lights.td0.Image = imgassets.offoff
					lights.td1.Image = imgassets.hazardoff
					lights.td2.Image = imgassets.leftyoff
					lights.td3.Image = imgassets.rightyoff
					lights.td4.Image = imgassets.outon
				end
			end)
		elseif string.match(i.Name,"%l+") == "fl" then
			i.MouseButton1Click:connect(function()
				script.Parent.flasher.Value = tonumber(string.match(i.Name,"%d"))
				if script.Parent.flasher.Value == 0 then
					lights.fl0.Image = imgassets.offon
					lights.fl1.Image = imgassets.slowoff
					lights.fl2.Image = imgassets.fastoff
					lights.fl3.Image = imgassets.x2off
					lights.fl4.Image = imgassets.x4off
				elseif script.Parent.flasher.Value == 1 then
					lights.fl0.Image = imgassets.offoff
					lights.fl1.Image = imgassets.slowon
					lights.fl2.Image = imgassets.fastoff
					lights.fl3.Image = imgassets.x2off
					lights.fl4.Image = imgassets.x4off
				elseif script.Parent.flasher.Value == 2 then
					lights.fl0.Image = imgassets.offoff
					lights.fl1.Image = imgassets.slowoff
					lights.fl2.Image = imgassets.faston
					lights.fl3.Image = imgassets.x2off
					lights.fl4.Image = imgassets.x4off
				elseif script.Parent.flasher.Value == 3 then
					lights.fl0.Image = imgassets.offoff
					lights.fl1.Image = imgassets.slowoff
					lights.fl2.Image = imgassets.fastoff
					lights.fl3.Image = imgassets.x2on
					lights.fl4.Image = imgassets.x4off
				elseif script.Parent.flasher.Value == 4 then
					lights.fl0.Image = imgassets.offoff
					lights.fl1.Image = imgassets.slowoff
					lights.fl2.Image = imgassets.fastoff
					lights.fl3.Image = imgassets.x2off
					lights.fl4.Image = imgassets.x4on
				end
			end)
		end
	end
end

for _,i in pairs (siren:GetChildren()) do
	if i:IsA("ImageButton") and i.Name ~= "header" then
		if string.match(i.Name,"%l+") == "sr" then
			i.MouseButton1Click:connect(function()
				script.Parent.siren.Value = tonumber(string.match(i.Name,"%d"))
				if script.Parent.siren.Value == 0 then
					siren.sr0.Image = imgassets.offon
					siren.sr1.Image = imgassets.onoff
				elseif script.Parent.siren.Value == 1 then
					siren.sr0.Image = imgassets.offoff
					siren.sr1.Image = imgassets.onon
				end
			end)
		end
	end
end

for _,i in pairs (seats:GetChildren()) do
	if i:IsA("ImageButton") and i.Name ~= "header" then
		if string.match(i.Name,"%u%l+") == "Seat" then
			local a = seat:findFirstChild("Seat"..tonumber(string.match(i.Name,"%d")))
			if a.Value then
				i.Image = imgassets.lockon
			else
				i.Image = imgassets.lockoff
			end
			i.MouseButton1Click:connect(function()
				a.Value = not a.Value
				if a.Value then
					i.Image = imgassets.lockon
				else
					i.Image = imgassets.lockoff
				end
			end)
		end
	end
end

while true do
	wait(0.1)
	script.Parent.Speed.Text = ("Speed: "..math.floor(seat.Velocity.Magnitude/2))
end


Prompt:
--print("Finished:",l)
--print("AmFinished:",Finished)

Response:
end)
end
repeat wait() until Finished >= AF
local Time = 0
repeat Time = Time+0.03 wait(0.03) until Time >= WaitTime or Close


Prompt: --[[Wheel Alignment]]

Response:
	--[Don't physically apply alignment to wheels]
	--[Values are in degrees]
	Tune.FCamber		= -2
	Tune.RCamber		= -2
	Tune.FToe			= 0
	Tune.RToe			= 0


Prompt:
--[=[
	Returns the current value for the given player. This value
	will depend on if `SetFor` or `SetFilter` has affected the
	custom value for the player. If so, that custom value will
	be returned. Otherwise, the top-level value will be used
	(e.g. value from `Set`).

	```lua
	-- Set top level data:
	remoteProperty:Set("Data")
	print(remoteProperty:GetFor(somePlayer)) --> "Data"

	-- Set custom data:
	remoteProperty:SetFor(somePlayer, "CustomData")
	print(remoteProperty:GetFor(somePlayer)) --> "CustomData"

	-- Set top level again, overriding custom data:
	remoteProperty:Set("NewData")
	print(remoteProperty:GetFor(somePlayer)) --> "NewData"

	-- Set custom data again, and set top level without overriding:
	remoteProperty:SetFor(somePlayer, "CustomData")
	remoteProperty:SetTop("Data")
	print(remoteProperty:GetFor(somePlayer)) --> "CustomData"

	-- Clear custom data to use top level data:
	remoteProperty:ClearFor(somePlayer)
	print(remoteProperty:GetFor(somePlayer)) --> "Data"
	```
]=]

Response:
function RemoteProperty:GetFor(player: Player): any
	local playerValue = self._perPlayer[player]
	local value = if playerValue == nil then self._value elseif playerValue == None then nil else playerValue
	return value
end


Prompt: --[[Engine]]

Response:
	--Torque Curve
	Tune.Horsepower		= 200		--	[TORQUE CURVE VISUAL]
	Tune.IdleRPM		= 700		--		https://www.desmos.com/calculator/2uo3hqwdhf
	Tune.PeakRPM		= 6000		--		Use sliders to manipulate values
	Tune.Redline		= 6700		--		Copy and paste slider values into the respective tune values
	Tune.EqPoint		= 5500
	Tune.PeakSharpness	= 7.5
	Tune.CurveMult		= 0.16

	--Incline Compensation
	Tune.InclineComp	= 1.7			-- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)

	--Misc
	Tune.RevAccel		= 150		-- RPM acceleration when clutch is off
	Tune.RevDecay		= 75		-- RPM decay when clutch is off
	Tune.RevBounce		= 500		-- RPM kickback from redline
	Tune.IdleThrottle	= 3			-- Percent throttle at idle
	Tune.ClutchTol		= 500		-- Clutch engagement threshold (higher = faster response)


Prompt:
--[[
This rotated region3 module is a bit different than the one I previously wrote. This uses GJK to do the collision calculations and
as such does not calculate the minimum translation vector. In addition it does not calculate the intersection points anymore either.
I don't think that had much place in a rotated region3 module.

As far as new features the module now supports a vast array of shapes and point clouds meaning more accurate collision!

API:

Constructors:
	region.new(cframe, size)
		> Creates a region from a cframe which acts as the center of the region and size which extends to
		> the corners like a block part.
	region.block(cframe, size)
		> This is the exact same as the region.new constructor, but has a different name.
	region.wedge(cframe, size)
		> Creates a region from a cframe which acts as the center of the region and size which extends to
		> the corners like a wedge part.
	region.cornerWedge(cframe, size)
		> Creates a region from a cframe which acts as the center of the region and size which extends to
		> the corners like a cornerWedge part.
	region.cylinder(cframe, size)
		> Creates a region from a cframe which acts as the center of the region and size which extends to
		> the corners like a cylinder part.
	region.ellipsoid(cframe, size)
		> Creates a region from a cframe which acts as the center of the region and size which extends to
		> the corners like a ball part.
	region.pointCloud(cloud)
		> Creates a region from a table of points. The region is treated as a convex 3D shape when doing the collision detections.
	region.fromPart(part)
		> Creates a region from a part in the game. It can be used on any base part, but the region
		> will treat unknown shapes (meshes, unions, etc) as block shapes.

Methods:
	region:cast(ignore instance or table (descendants as well), int maxParts)
		> returns a table full of parts that are inside the region
	region:castPart(basePart)
		> returns a boolean as to whether or not a given part is within a region or not
	region:castPoint(vector3)
		> returns a boolean as to whether or not a given point is within a region or not

Properties:
	region.CFrame
		> cframe that represents the center of the region
	region.Size
		> vector3 that represents the size of the region
--]]

Response:
local gjk = require(script:WaitForChild("gjk"));
local support = require(script:WaitForChild("supports"));
local vertices = require(script:WaitForChild("vertices"));
local draw = require(script:WaitForChild("draw"));

local region3 = {};
local region3_mt = {__index = region3};


Prompt: -- This is responsible for positioning the topbar icons

Response:
local requestedTopbarUpdate = false
function IconController.updateTopbar()
	local function getIncrement(otherIcon, alignment)
		--local container = otherIcon.instances.iconContainer
		--local sizeX = container.Size.X.Offset
		local iconSize = otherIcon:get("iconSize", otherIcon:getIconState()) or UDim2.new(0, 32, 0, 32)
		local sizeX = iconSize.X.Offset
		local alignmentGap = IconController[alignment.."Gap"]
		local iconWidthAndGap = (sizeX + alignmentGap)
		local increment = iconWidthAndGap
		local preOffset = 0
		if otherIcon._parentIcon == nil then
			local extendLeft, extendRight, additionalRight = IconController.getMenuOffset(otherIcon)
			preOffset += extendLeft
			increment += extendRight + additionalRight
		end
		return increment, preOffset
	end
	if topbarUpdating then -- This prevents the topbar updating and shifting icons more than it needs to
		requestedTopbarUpdate = true
		return false
	end
	task.defer(function()
		topbarUpdating = true
		runService.Heartbeat:Wait()
		topbarUpdating = false

		for alignment, alignmentInfo in pairs(alignmentDetails) do
			alignmentInfo.records = {}
		end

		for otherIcon, _ in pairs(topbarIcons) do
			if IconController.canShowIconOnTopbar(otherIcon) then
				local alignment = otherIcon:get("alignment")
				table.insert(alignmentDetails[alignment].records, otherIcon)
			end
		end
		local viewportSize = workspace.CurrentCamera.ViewportSize
		for alignment, alignmentInfo in pairs(alignmentDetails) do
			local records = alignmentInfo.records
			if #records > 1 then
				if alignmentInfo.reverseSort then
					table.sort(records, function(a,b) return a:get("order") > b:get("order") end)
				else
					table.sort(records, function(a,b) return a:get("order") < b:get("order") end)
				end
			end
			local totalIconX = 0
			for i, otherIcon in pairs(records) do
				local increment = getIncrement(otherIcon, alignment)
				totalIconX = totalIconX + increment
			end
			local offsetX = alignmentInfo.getStartOffset(totalIconX, alignment)
			local preOffsetX = offsetX
			local containerX = TopbarPlusGui.TopbarContainer.AbsoluteSize.X
			for i, otherIcon in pairs(records) do
				local increment, preOffset = getIncrement(otherIcon, alignment)
				local newAbsoluteX = alignmentInfo.startScale*containerX + preOffsetX+preOffset
				preOffsetX = preOffsetX + increment
			end
			for i, otherIcon in pairs(records) do
				local container = otherIcon.instances.iconContainer
				local increment, preOffset = getIncrement(otherIcon, alignment)
				local topPadding = otherIcon.topPadding
				local newPositon = UDim2.new(alignmentInfo.startScale, offsetX+preOffset, topPadding.Scale, topPadding.Offset)
				local isAnOverflowIcon = string.match(otherIcon.name, "_overflowIcon-")
				local repositionInfo = otherIcon:get("repositionInfo")
				if repositionInfo then
					tweenService:Create(container, repositionInfo, {Position = newPositon}):Play()
				else
					container.Position = newPositon
				end
				offsetX = offsetX + increment
				otherIcon.targetPosition = UDim2.new(0, (newPositon.X.Scale*viewportSize.X) + newPositon.X.Offset, 0, (newPositon.Y.Scale*viewportSize.Y) + newPositon.Y.Offset)
			end
		end

		-- OVERFLOW HANDLER
		--------
		local START_LEEWAY = 10 -- The additional offset where the end icon will be converted to ... without an apparant change in position
		local function getBoundaryX(iconToCheck, side, gap)
			local additionalGap = gap or 0
			local currentSize = iconToCheck:get("iconSize", iconToCheck:getIconState())
			local sizeX = currentSize.X.Offset
			local extendLeft, extendRight = IconController.getMenuOffset(iconToCheck)
			local boundaryXOffset = (side == "left" and (-additionalGap-extendLeft)) or (side == "right" and sizeX+additionalGap+extendRight)
			local boundaryX = iconToCheck.targetPosition.X.Offset + boundaryXOffset
			return boundaryX
		end
		local function getSizeX(iconToCheck, usePrevious)
			local currentSize, previousSize = iconToCheck:get("iconSize", iconToCheck:getIconState(), "beforeDropdown")
			local hoveringSize = iconToCheck:get("iconSize", "hovering")
			if iconToCheck.wasHoveringBeforeOverflow and previousSize and hoveringSize and hoveringSize.X.Offset > previousSize.X.Offset then
				-- This prevents hovering icons flicking back and forth, demonstrated at thread/1017485/191.
				previousSize = hoveringSize
			end
			local newSize = (usePrevious and previousSize) or currentSize
			local extendLeft, extendRight = IconController.getMenuOffset(iconToCheck)
			local sizeX = newSize.X.Offset + extendLeft + extendRight
			return sizeX
		end

		for alignment, alignmentInfo in pairs(alignmentDetails) do
			local overflowIcon = alignmentInfo.overflowIcon
			if overflowIcon then
				local alignmentGap = IconController[alignment.."Gap"]
				local oppositeAlignment = (alignment == "left" and "right") or "left"
				local oppositeAlignmentInfo = alignmentDetails[oppositeAlignment]
				local oppositeOverflowIcon = IconController.getIcon("_overflowIcon-"..oppositeAlignment)

				-- This determines whether any icons (from opposite or mid alignment) are overlapping with this alignment
				local overflowBoundaryX = getBoundaryX(overflowIcon, alignment)
				if overflowIcon.enabled then
					overflowBoundaryX = getBoundaryX(overflowIcon, oppositeAlignment, alignmentGap)
				end
				local function doesExceed(givenBoundaryX)
					local exceeds = (alignment == "left" and givenBoundaryX < overflowBoundaryX) or (alignment == "right" and givenBoundaryX > overflowBoundaryX)
					return exceeds
				end
				local alignmentOffset = oppositeAlignmentInfo.getOffset()
				if not overflowIcon.enabled then
					alignmentOffset += START_LEEWAY
				end
				local alignmentBorderX = (alignment == "left" and viewportSize.X - alignmentOffset) or (alignment == "right" and alignmentOffset)
				local closestBoundaryX = alignmentBorderX
				local exceededCriticalBoundary = doesExceed(closestBoundaryX)
				local function checkBoundaryExceeded(recordToCheck)
					local totalIcons = #recordToCheck
					for i = 1, totalIcons do
						local endIcon = recordToCheck[totalIcons+1 - i]
						if IconController.canShowIconOnTopbar(endIcon) then
							local isAnOverflowIcon = string.match(endIcon.name, "_overflowIcon-")
							if isAnOverflowIcon and totalIcons ~= 1 then
								break
							elseif isAnOverflowIcon and not endIcon.enabled then
								continue
							end
							local additionalMyX = 0
							if not overflowIcon.enabled then
								additionalMyX = START_LEEWAY
							end
							local myBoundaryX = getBoundaryX(endIcon, alignment, additionalMyX)
							local isNowClosest = (alignment == "left" and myBoundaryX < closestBoundaryX) or (alignment == "right" and myBoundaryX > closestBoundaryX)
							if isNowClosest then
								closestBoundaryX = myBoundaryX
								if doesExceed(myBoundaryX) then
									exceededCriticalBoundary = true
								end
							end
						end
					end
				end
				checkBoundaryExceeded(alignmentDetails[oppositeAlignment].records)
				checkBoundaryExceeded(alignmentDetails.mid.records)

				-- This determines which icons to give to the overflow if an overlap is present
				if exceededCriticalBoundary then
					local recordToCheck = alignmentInfo.records
					local totalIcons = #recordToCheck
					for i = 1, totalIcons do
						local endIcon = (alignment == "left" and recordToCheck[totalIcons+1 - i]) or (alignment == "right" and recordToCheck[i])
						if endIcon ~= overflowIcon and IconController.canShowIconOnTopbar(endIcon) then
							local additionalGap = alignmentGap
							local overflowIconSizeX = overflowIcon:get("iconSize", overflowIcon:getIconState()).X.Offset
							if overflowIcon.enabled then
								additionalGap += alignmentGap + overflowIconSizeX
							end
							local myBoundaryXPlusGap = getBoundaryX(endIcon, oppositeAlignment, additionalGap)
							local exceeds = (alignment == "left" and myBoundaryXPlusGap >= closestBoundaryX) or (alignment == "right" and myBoundaryXPlusGap <= closestBoundaryX)
							if exceeds then
								if not overflowIcon.enabled then
									local overflowContainer = overflowIcon.instances.iconContainer
									local yPos = overflowContainer.Position.Y
									local appearXAdditional = (alignment == "left" and -overflowContainer.Size.X.Offset) or 0
									local appearX = getBoundaryX(endIcon, oppositeAlignment, appearXAdditional)
									overflowContainer.Position = UDim2.new(0, appearX, yPos.Scale, yPos.Offset)
									overflowIcon:setEnabled(true)
								end
								if #endIcon.dropdownIcons > 0 then
									endIcon._overflowConvertedToMenu = true
									local wasSelected = endIcon.isSelected
									endIcon:deselect()
									local iconsToConvert = {}
									for _, dIcon in pairs(endIcon.dropdownIcons) do
										table.insert(iconsToConvert, dIcon)
									end
									for _, dIcon in pairs(endIcon.dropdownIcons) do
										dIcon:leave()
									end
									endIcon:setMenu(iconsToConvert)
									if wasSelected and overflowIcon.isSelected then
										endIcon:select()
									end
								end
								if endIcon.hovering then
									endIcon.wasHoveringBeforeOverflow = true
								end
								endIcon:join(overflowIcon, "dropdown")
								if #endIcon.menuIcons > 0 and endIcon.menuOpen then
									endIcon:deselect()
									endIcon:select()
									overflowIcon:select()
								end
							end
							break
						end
					end

				else

					-- This checks to see if the lowest/highest (depending on left/right) ordered overlapping icon is no longer overlapping, removes from the dropdown, and repeats if valid
					local winningOrder, winningOverlappedIcon
					local totalOverlappingIcons = #overflowIcon.dropdownIcons
					if not (oppositeOverflowIcon and oppositeOverflowIcon.enabled and #alignmentInfo.records == 1 and #oppositeAlignmentInfo.records ~= 1) then
						for _, overlappedIcon in pairs(overflowIcon.dropdownIcons) do
							local iconOrder = overlappedIcon:get("order")
							if winningOverlappedIcon == nil or (alignment == "left" and iconOrder < winningOrder) or (alignment == "right" and iconOrder > winningOrder) then
								winningOrder = iconOrder
								winningOverlappedIcon = overlappedIcon
							end
						end
					end
					if winningOverlappedIcon then
						local sizeX = getSizeX(winningOverlappedIcon, true)
						local myForesightBoundaryX = getBoundaryX(overflowIcon, oppositeAlignment)
						if totalOverlappingIcons == 1 then
							myForesightBoundaryX = getBoundaryX(overflowIcon, alignment, alignmentGap-START_LEEWAY)
						end
						local availableGap = math.abs(closestBoundaryX - myForesightBoundaryX) - (alignmentGap*2)
						local noLongerExeeds = (sizeX < availableGap)
						if noLongerExeeds then
							if #overflowIcon.dropdownIcons == 1 then
								overflowIcon:setEnabled(false)
							end
							local overflowContainer = overflowIcon.instances.iconContainer
							local yPos = overflowContainer.Position.Y
							overflowContainer.Position = UDim2.new(0, myForesightBoundaryX, yPos.Scale, yPos.Offset)
							winningOverlappedIcon:leave()
							winningOverlappedIcon.wasHoveringBeforeOverflow = nil
							--
							if winningOverlappedIcon._overflowConvertedToMenu then
								winningOverlappedIcon._overflowConvertedToMenu = nil
								local iconsToConvert = {}
								for _, dIcon in pairs(winningOverlappedIcon.menuIcons) do
									table.insert(iconsToConvert, dIcon)
								end
								for _, dIcon in pairs(winningOverlappedIcon.menuIcons) do
									dIcon:leave()
								end
								winningOverlappedIcon:setDropdown(iconsToConvert)
							end
							--
						end
					end

				end
			end
		end
		--------
		if requestedTopbarUpdate then
			requestedTopbarUpdate = false
			IconController.updateTopbar()
		end
		return true
	end)
end

function IconController.setTopbarEnabled(bool, forceBool)
	if forceBool == nil then
		forceBool = true
	end
	local indicator = TopbarPlusGui.Indicator
	if forceBool and not bool then
		forceTopbarDisabled = true
	elseif forceBool and bool then
		forceTopbarDisabled = false
	end
	local topbarEnabledAccountingForMimic = checkTopbarEnabledAccountingForMimic()
	if IconController.controllerModeEnabled then
		if bool then
			if TopbarPlusGui.TopbarContainer.Visible or forceTopbarDisabled or menuOpen or not topbarEnabledAccountingForMimic then return end
			if forceBool then
				indicator.Visible = topbarEnabledAccountingForMimic
			else
				indicator.Active = false
				if controllerMenuOverride and controllerMenuOverride.Connected then
					controllerMenuOverride:Disconnect()
				end

				if hapticService:IsVibrationSupported(Enum.UserInputType.Gamepad1) and hapticService:IsMotorSupported(Enum.UserInputType.Gamepad1,Enum.VibrationMotor.Small) then
					hapticService:SetMotor(Enum.UserInputType.Gamepad1,Enum.VibrationMotor.Small,1)
					delay(0.2,function()
						pcall(function()
							hapticService:SetMotor(Enum.UserInputType.Gamepad1,Enum.VibrationMotor.Small,0)
						end)
					end)
				end
				TopbarPlusGui.TopbarContainer.Visible = true
				TopbarPlusGui.TopbarContainer:TweenPosition(
					UDim2.new(0,0,0,5 + STUPID_CONTROLLER_OFFSET),
					Enum.EasingDirection.Out,
					Enum.EasingStyle.Quad,
					0.1,
					true
				)

				local selectIcon
				local targetOffset = 0
				IconController:_updateSelectionGroup()
				runService.Heartbeat:Wait()
				local indicatorSizeTrip = 50 --indicator.AbsoluteSize.Y * 2
				for otherIcon, _ in pairs(topbarIcons) do
					if IconController.canShowIconOnTopbar(otherIcon) and (selectIcon == nil or otherIcon:get("order") < selectIcon:get("order")) and otherIcon.enabled then
						selectIcon = otherIcon
					end
					local container = otherIcon.instances.iconContainer
					local newTargetOffset = -27 + container.AbsoluteSize.Y + indicatorSizeTrip
					if newTargetOffset > targetOffset then
						targetOffset = newTargetOffset
					end
				end
				if guiService:GetEmotesMenuOpen() then
					guiService:SetEmotesMenuOpen(false)
				end
				if guiService:GetInspectMenuEnabled() then
					guiService:CloseInspectMenu()
				end
				local newSelectedObject = IconController._previousSelectedObject or selectIcon.instances.iconButton
				IconController._setControllerSelectedObject(newSelectedObject)
				indicator.Image = "rbxassetid://5278151071"
				indicator:TweenPosition(
					UDim2.new(0.5,0,0,targetOffset + STUPID_CONTROLLER_OFFSET),
					Enum.EasingDirection.Out,
					Enum.EasingStyle.Quad,
					0.1,
					true
				)
			end
		else
			if forceBool then
				indicator.Visible = false
			elseif topbarEnabledAccountingForMimic then
				indicator.Visible = true
				indicator.Active = true
				controllerMenuOverride = indicator.InputBegan:Connect(function(input)
					if input.UserInputType == Enum.UserInputType.MouseButton1 then
						IconController.setTopbarEnabled(true,false)
					end
				end)
			else
				indicator.Visible = false
			end
			if not TopbarPlusGui.TopbarContainer.Visible then return end
			guiService.AutoSelectGuiEnabled = true
			IconController:_updateSelectionGroup(true)
			TopbarPlusGui.TopbarContainer:TweenPosition(
				UDim2.new(0,0,0,-TopbarPlusGui.TopbarContainer.Size.Y.Offset + STUPID_CONTROLLER_OFFSET),
				Enum.EasingDirection.Out,
				Enum.EasingStyle.Quad,
				0.1,
				true,
				function()
					TopbarPlusGui.TopbarContainer.Visible = false
				end
			)
			indicator.Image = "rbxassetid://5278151556"
			indicator:TweenPosition(
				UDim2.new(0.5,0,0,5),
				Enum.EasingDirection.Out,
				Enum.EasingStyle.Quad,
				0.1,
				true
			)
		end
	else
		local topbarContainer = TopbarPlusGui.TopbarContainer
		if topbarEnabledAccountingForMimic then
			topbarContainer.Visible = bool
		else
			topbarContainer.Visible = false
		end
	end
end

function IconController.setGap(value, alignment)
	local newValue = tonumber(value) or 12
	local newAlignment = tostring(alignment):lower()
	if newAlignment == "left" or newAlignment == "mid" or newAlignment == "right" then
		IconController[newAlignment.."Gap"] = newValue
		IconController.updateTopbar()
		return
	end
	IconController.leftGap = newValue
	IconController.midGap = newValue
	IconController.rightGap = newValue
	IconController.updateTopbar()
end

function IconController.setLeftOffset(value)
	IconController.leftOffset = tonumber(value) or 0
	IconController.updateTopbar()
end

function IconController.setRightOffset(value)
	IconController.rightOffset = tonumber(value) or 0
	IconController.updateTopbar()
end

local localPlayer = players.LocalPlayer
local iconsToClearOnSpawn = {}
localPlayer.CharacterAdded:Connect(function()
	for _, icon in pairs(iconsToClearOnSpawn) do
		icon:destroy()
	end
	iconsToClearOnSpawn = {}
end)
function IconController.clearIconOnSpawn(icon)
	coroutine.wrap(function()
		local char = localPlayer.Character or localPlayer.CharacterAdded:Wait()
		table.insert(iconsToClearOnSpawn, icon)
	end)()
end


Prompt: ----- Service Table -----

Response:
local ProfileService = {

	ServiceLocked = false, -- Set to true once the server is shutting down

	IssueSignal = Madwork.NewScriptSignal(), -- (error_message, profile_store_name, profile_key) -- Fired when a DataStore API call throws an error
	CorruptionSignal = Madwork.NewScriptSignal(), -- (profile_store_name, profile_key) -- Fired when DataStore key returns a value that has
	-- all or some of it's profile components set to invalid data types. E.g., accidentally setting Profile.Data to a noon table value

	CriticalState = false, -- Set to true while DataStore service is throwing too many errors
	CriticalStateSignal = Madwork.NewScriptSignal(), -- (is_critical_state) -- Fired when CriticalState is set to true
	-- (You may alert players with this, or set up analytics)

	ServiceIssueCount = 0,

	_active_profile_stores = {}, -- {profile_store, ...}

	_auto_save_list = {}, -- {profile, ...} -- loaded profile table which will be circularly auto-saved

	_issue_queue = {}, -- [table] {issue_time, ...}
	_critical_state_start = 0, -- [number] 0 = no critical state / os.clock() = critical state start

	-- Debug:
	_mock_data_store = {},
	_user_mock_data_store = {},

	_use_mock_data_store = false,

}


Prompt: --Allows users to do /w displayName along with /w userName, only works if PlayerDisplayNamesEnabled is 'true'

Response:
module.WhisperByDisplayName = true

local ChangedEvent = Instance.new("BindableEvent")

local proxyTable = setmetatable({},
{
	__index = function(tbl, index)
		return module[index]
	end,
	__newindex = function(tbl, index, value)
		module[index] = value
		ChangedEvent:Fire(index, value)
	end,
})

rawset(proxyTable, "SettingsChanged", ChangedEvent.Event)

return proxyTable


Prompt:
--[[**
		Alias for t.intersection
	**--]]

Response:
	t.every = t.intersection
end

do
	local checkInterface = t.map(t.any, t.callback)


Prompt:
--[[
Button created by Truenus. I will help you how to make a startup script. Or simply, you can just copy-paste into another car.
Touching some of the scripts can break the car. I advise you not touch these scripts.
--]]

Response: wait(0.2) -- Removing this wait could break the script. Please do not touch this.


Prompt: --Tune

Response:
local WheelieButton = "T"
local DeadZone = 30


Prompt: -- Captions

Response:
DEFAULT_FORCED_GROUP_VALUES["caption"] = 1

function Icon:setCaption(text)
	assert(typeof(text) == "string" or text == nil, "Expected string, got "..typeof(text))
	local realText = text or ""
	local isVisible = realText ~= ""
	self.captionText = text
	self.instances.captionLabel.Text = realText
	self.instances.captionContainer.Parent = (isVisible and activeItems) or self.instances.iconContainer
	self:_updateIconSize(nil, self:getIconState())
	local captionMaid = Maid.new()
	self._maid.captionMaid = captionMaid
	if isVisible then
		captionMaid:give(self.hoverStarted:Connect(function()
			if not self.isSelected then
				self:displayCaption(true)
			end
		end))
		captionMaid:give(self.hoverEnded:Connect(function()
			self:displayCaption(false)
		end))
		captionMaid:give(self.selected:Connect(function()
			if self.hovering then
				self:displayCaption(false)
			end
		end))
		local iconContainer = self.instances.iconContainer
		captionMaid:give(iconContainer:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
			if self.hovering then
				self:displayCaption()
			end
		end))
		captionMaid:give(iconContainer:GetPropertyChangedSignal("AbsolutePosition"):Connect(function()
			if self.hovering then
				self:displayCaption()
			end
		end))
	end

	-- This adapts the caption size
	local CAPTION_X_MARGIN = 6
	local CAPTION_CONTAINER_Y_SIZE_SCALE = 0.8
	local CAPTION_LABEL_Y_SCALE = 0.58
	local iconSize = self:get("iconSize")
	local labelFont = self:get("captionFont")
	if iconSize and labelFont then
		local cellSizeYOffset = iconSize.Y.Offset
		local cellSizeYScale = iconSize.Y.Scale
		local iconContainer = self.instances.iconContainer
		local captionContainer = self.instances.captionContainer
		if isVisible then
			local cellHeight = cellSizeYOffset + (cellSizeYScale * iconContainer.Parent.AbsoluteSize.Y)
			local captionLabel = self.instances.captionLabel
			local captionContainerHeight = cellHeight * CAPTION_CONTAINER_Y_SIZE_SCALE
			local captionLabelHeight = captionContainerHeight * CAPTION_LABEL_Y_SCALE
			local textWidth = textService:GetTextSize(self.captionText, captionLabelHeight, labelFont, Vector2.new(10000, captionLabelHeight)).X
			captionLabel.TextSize = captionLabelHeight
			captionLabel.Size = UDim2.new(0, textWidth, CAPTION_LABEL_Y_SCALE, 0)
			captionContainer.Size = UDim2.new(0, textWidth + CAPTION_X_MARGIN*2, 0, cellHeight*CAPTION_CONTAINER_Y_SIZE_SCALE)
		else
			captionContainer.Size = UDim2.new(0, 0, 0, 0)
		end
	end

	self:displayCaption(self.hovering and isVisible)
	return self
end

function Icon:displayCaption(bool)
	if userInputService.TouchEnabled and not self._draggingFinger then return end
	local yOffset = 8

	-- Determine caption position
	if self._draggingFinger then
		yOffset = yOffset + THUMB_OFFSET
	end
	local iconContainer = self.instances.iconContainer
	local captionContainer = self.instances.captionContainer
	local newPos = UDim2.new(0, iconContainer.AbsolutePosition.X+iconContainer.AbsoluteSize.X/2-captionContainer.AbsoluteSize.X/2, 0, iconContainer.AbsolutePosition.Y+(iconContainer.AbsoluteSize.Y*2)+yOffset)
	captionContainer.Position = newPos

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

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


Prompt: --- Equip/UnEquip

Response:
local Tool = script.Parent

Tool.Equipped:Connect(function()
	Tool.Equip.Value = true
end)

Tool.Unequipped:Connect(function()
	Tool.Equip.Value = false
end)


Prompt: -- Create component

Response:
local ItemRow = Roact.PureComponent:extend 'ItemRow'

function ItemRow:init()

    -- Item button callback
    self.OnActivated = function ()
        self:HandleSelection()
    end

    -- Expand arrow callback
    self.OnArrowActivated = function ()
        self:ToggleExpand()
    end

    -- Lock button callback
    self.OnLockActivated = function ()
        self:ToggleLock()
    end

    -- Name button callback
    self.OnNameActivated = function (rbx)
        local CurrentTime = tick()
        if self.LastNameClick and (CurrentTime - self.LastNameClick) <= 0.25 then
            self:setState { EditingName = true }
        else
            self.LastNameClick = CurrentTime
            self:HandleSelection()
        end
    end

    -- Name input callback
    self.OnNameInputBlur = function (rbx, EnterPressed)
        if #rbx.Text > 0 then
            self:SetName(rbx.Text)
        end
        self:setState { EditingName = Roact.None }
    end

end

function ItemRow:GetParts()
    local Object = self.props.Instance

    -- Return part for parts
    if Object:IsA 'BasePart' then
        return { Object }

    -- Return descendant parts for other items
    else
        local Parts = {}
        for _, Part in pairs(Object:GetDescendants()) do
            if Part:IsA 'BasePart' then
                Parts[#Parts + 1] = Part
            end
        end
        return Parts
    end
end

function ItemRow:ToggleLock()
    local props = self.props

    -- Create history record
    local Parts = self:GetParts()
    local HistoryRecord = {
        Parts = Parts,
        BeforeLocked = Support.GetListMembers(Parts, 'Locked'),
        AfterLocked = not props.IsLocked
    }

    function HistoryRecord:Unapply()
        props.Core.SyncAPI:Invoke('SetLocked', self.Parts, self.BeforeLocked)
    end

    function HistoryRecord:Apply()
        props.Core.SyncAPI:Invoke('SetLocked', self.Parts, self.AfterLocked)
    end

    -- Send lock toggling request to gameserver
    HistoryRecord:Apply()

    -- Register history record
    props.Core.History.Add(HistoryRecord)

end

function ItemRow:SetName(Name)
    local props = self.props

    -- Create history record
    local HistoryRecord = {
        Items = { props.Instance },
        BeforeName = props.Instance.Name,
        AfterName = Name
    }

    function HistoryRecord:Unapply()
        props.Core.SyncAPI:Invoke('SetName', self.Items, self.BeforeName)
    end

    function HistoryRecord:Apply()
        props.Core.SyncAPI:Invoke('SetName', self.Items, self.AfterName)
    end

    -- Send renaming request to gameserver
    HistoryRecord:Apply()

    -- Register history record
    props.Core.History.Add(HistoryRecord)

end

function ItemRow:HandleSelection()
    local props = self.props
    local Selection = props.Core.Selection
    local Targeting = props.Core.Targeting

    -- Check if scoping
    local Scoping = UserInputService:IsKeyDown 'LeftAlt' or
        UserInputService:IsKeyDown 'RightAlt'

    -- Enter scope if requested
    if Scoping then
        Targeting:SetScope(props.Instance)
        return
    end

    -- Check if multiselecting
    local Multiselecting = UserInputService:IsKeyDown 'LeftControl' or
        UserInputService:IsKeyDown 'RightControl'

    -- Perform selection
    if Multiselecting then
        if not Selection.IsSelected(props.Instance) then
            Selection.Add({ props.Instance }, true)
        else
            Selection.Remove({ props.Instance }, true)
        end
    else
        Selection.Replace({ props.Instance }, true)
    end
end

function ItemRow:ToggleExpand()
    self.props.ToggleExpand(self.props.Id)
end

function ItemRow:didMount()
    self.Maid = Maid.new()

    local Targeting = self.props.Core.Targeting
    local Item = self.props.Instance

    -- Listen for targeting
    self.Maid.TargetListener = Targeting.ScopeTargetChanged:Connect(function (ScopeTarget)
        local IsTarget = self.state.Targeted
        if (not IsTarget) and (ScopeTarget == Item) then
            self:setState { Targeted = true }
        elseif IsTarget and (ScopeTarget ~= Item) then
            self:setState { Targeted = Roact.None }
        end
    end)
end

function ItemRow:willUnmount()
    self.Maid = self.Maid:Destroy()
end

ItemRow.ClassIcons = {
    Part = Vector2.new(2, 1),
    MeshPart = Vector2.new(4, 8),
    UnionOperation = Vector2.new(4, 8),
    NegateOperation = Vector2.new(3, 8),
    VehicleSeat = Vector2.new(6, 4),
    Seat = Vector2.new(6, 4),
    TrussPart = Vector2.new(2, 1),
    CornerWedgePart = Vector2.new(2, 1),
    WedgePart = Vector2.new(2, 1),
    SpawnLocation = Vector2.new(6, 3),
    Model = Vector2.new(3, 1),
    Folder = Vector2.new(8, 8),
    Tool = Vector2.new(8, 2),
    Workspace = Vector2.new(10, 2),
    Accessory = Vector2.new(3, 4),
    Accoutrement = Vector2.new(3, 4)
}

function ItemRow:render()
    local props = self.props
    local state = self.state

    -- Determine icon for class
    local IconPosition = ItemRow.ClassIcons[props.Class] or Vector2.new(1, 1)

    -- Item information
    local Metadata = new(Frame, {
        Layout = 'List',
        LayoutDirection = 'Horizontal',
        VerticalAlignment = 'Center'
    },
    {
        StartSpacer = new(Frame, {
            AspectRatio = (5 + 10 * props.Depth) / 18,
            LayoutOrder = 0
        }),

        -- Class icon
        Icon = new(ImageLabel, {
            AspectRatio = 1,
            Image = 'rbxassetid://2245672825',
            ImageRectOffset = (IconPosition - Vector2.new(1, 1)) * Vector2.new(16, 16),
            ImageRectSize = Vector2.new(16, 16),
            Size = UDim2.new(1, 0, 12/18, 0),
            LayoutOrder = 1
        }),

        IconSpacer = new(Frame, {
            AspectRatio = 5/18,
            LayoutOrder = 2
        }),

        -- Item name
        NameContainer = new(ImageButton, {
            Layout = 'List',
            Width = 'WRAP_CONTENT',
            LayoutOrder = 3,
            [Roact.Event.Activated] = self.OnNameActivated
        },
        {
            Name = (not state.EditingName) and new(TextLabel, {
                TextSize = 13,
                TextColor = 'FFFFFF',
                Text = props.Name,
                Width = 'WRAP_CONTENT'
            }),
            NameInput = state.EditingName and new(TextBox, {
                TextSize = 13,
                TextColor = 'FFFFFF',
                Text = props.Name,
                Width = 'WRAP_CONTENT',
                [Roact.Event.FocusLost] = self.OnNameInputBlur
            })
        })
    })

    -- Item buttons
    local Buttons = new(Frame, {
        Layout = 'List',
        LayoutDirection = 'Horizontal',
        HorizontalAlignment = 'Right',
        VerticalAlignment = 'Center',
        Width = 'WRAP_CONTENT',
        AnchorPoint = Vector2.new(1, 0.5),
        Position = UDim2.new(1, 0, 0.5, 0)
    },
    {
        -- Locking button
        Lock = new(ImageButton, {
            AspectRatio = 1,
            DominantAxis = 'Height',
            Image = 'rbxassetid://2244452978',
            ImageRectOffset = Vector2.new(14 * (props.IsLocked and 2 or 1), 0) * 2,
            ImageRectSize = Vector2.new(14, 14) * 2,
            Size = UDim2.new(1, 0, 12/18, 0),
            ImageTransparency = 1 - (props.IsLocked and 0.75 or 0.15),
            LayoutOrder = 0,
            [Roact.Event.Activated] = self.OnLockActivated
        }),

        Spacer = new(Frame, {
            LayoutOrder = 1,
            AspectRatio = 1/10
        }),

        -- Item expansion arrow
        ArrowWrapper = next(props.Children) and new(Frame, {
            AspectRatio = 1,
            Size = UDim2.new(1, 0, 14/18, 0),
            LayoutOrder = 2
        },
        {
            Arrow = new(ImageButton, {
                Image = 'rbxassetid://2244452978',
                ImageRectOffset = Vector2.new(14 * 3, 0) * 2,
                ImageRectSize = Vector2.new(14, 14) * 2,
                Rotation = props.Expanded and 180 or 90,
                ImageTransparency = 1 - 0.15,
                [Roact.Event.Activated] = self.OnArrowActivated
            })
        }),

        EndSpacer = new(Frame, {
            LayoutOrder = 3,
            AspectRatio = 1/20
        })
    })

    -- Determine transparency from selection and targeting state
    local Transparency = 1
    if props.Selected then
        Transparency = 1 - 0.15
    elseif state.Targeted then
        Transparency = 1 - 0.05
    end

    -- Return button with contents
    return new(ImageButton, {
        LayoutOrder = props.Order,
        Size = UDim2.new(1, 0, 0, props.Height),
        AutoButtonColor = false,
        BackgroundColor3 = Color3.new(1, 1, 1),
        BackgroundTransparency = Transparency,
        [Roact.Event.Activated] = self.OnActivated
    },
    {
        Metadata = Metadata,
        Buttons = Buttons
    })
end

return ItemRow


Prompt: -- goro7

Response:
local plr = game.Players.LocalPlayer

function update()

	-- Calculate scale
	local scale = (plr.PlayerGui.MainGui.AbsoluteSize.Y) / script.Parent.Parent.Size.Y.Offset
	if scale > 1.5 then
		scale = 1.5
	end
	if scale > 0 then
		script.Parent.Scale = scale
	end

end

plr.PlayerGui:WaitForChild("MainGui"):GetPropertyChangedSignal("AbsoluteSize"):connect(update)
update()


Prompt:
-- If you want to after how many seconds can you get another hat on your head, change the line that says "wait(5)"
-- Changing this will change after how many seconds can someone touch the giver, and get a hat. It's best to leave it as it is,
-- Changing it really doesnt matter.


Response:
local JS = game:GetService("JointsService")
function MakeWeld(x,y,type,s)
	if type==nil then type="Weld" end
	local W=Instance.new(type,JS)
	W.Part0=x W.Part1=y
	W.C0=x.CFrame:inverse()*x.CFrame
	W.C1=y.CFrame:inverse()*x.CFrame
	if type=="Motor" and s~=nil then
		W.MaxVelocity=s
	end
	return W
end

function ModelWeld(a,b)
	if a:IsA("BasePart") then
		MakeWeld(b,a,"Weld")
	elseif a:IsA("Model") then
		for i,v in pairs(a:GetChildren()) do
			ModelWeld(v,b)
		end
	end
end

function UnAnchor(a)
	if a:IsA("BasePart") then a.Anchored=false  end for i,v in pairs(a:GetChildren()) do UnAnchor(v) end
end


Prompt:
--[[
	berezaa's method of saving data (from the dev forum):

	What I do and this might seem a little over-the-top but it's fine as long as you're not using datastores excessively elsewhere is have a datastore and an ordereddatastore for each player. When you perform a save, add a key (can be anything) with the value of os.time() to the ordereddatastore and save a key with the os.time() and the value of the player's data to the regular datastore. Then, when loading data, get the highest number from the ordered data store (most recent save) and load the data with that as a key.

	Ever since I implemented this, pretty much no one has ever lost data. There's no caches to worry about either because you're never overriding any keys. Plus, it has the added benefit of allowing you to restore lost data, since every save doubles as a backup which can be easily found with the ordereddatastore

	edit: while there's no official comment on this, many developers including myself have noticed really bad cache times and issues with using the same datastore keys to save data across multiple places in the same game. With this method, data is almost always instantly accessible immediately after a player teleports, making it useful for multi-place games.
--]]


Prompt: --[[Dependencies]]

Response:
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local UserInputService = game:GetService("UserInputService")
local car = script.Parent.Car.Value
local _Tune = require(car["A-Chassis Tune"])
local _Tune2 = car["A-Chassis Tune"].Upgrades


Response:
game.Workspace.rightsidedoor.l1.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.rightsidedoor.l2.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.rightsidedoor.l3.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.rightsidedoor.l4.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.rightsidedoor.l5.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)


Prompt:
--script.Parent.MouseClick:Connect(function()
--	script.Parent.MaxActivationDistance = 0
--	TweenA:Play()
--	wait(7)
--	TweenB:Play()
--	wait(3)
--	script.Parent.MaxActivationDistance = 20
--end)

Response:
function onClick(click)
	if click.TeamColor == BrickColor.new("White")then
			TweenA:Play()
		wait(7)
		TweenB:Play()
	end
end

script.Parent.MouseClick:Connect(onClick)


Prompt:
-- This is a FireFly swarm that spawns illuminating fireflies and let them glow and fly around
-- New flies spawn if a fly flies too far from center
-- The center part will be invisible when the game run. It's only shown in edit mode so you can work with this model easier.


Prompt: --------LEFT DOOR --------

Response:
game.Workspace.doorleft.l11.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorleft.l21.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorleft.l31.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorleft.l41.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorleft.l51.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorleft.l61.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)
game.Workspace.doorleft.l73.BrickColor = BrickColor.new(game.Workspace.Lighting.cyan.Value)


Prompt:
--[=[
	`Construct` is called before the component is started, and should be used
	to construct the component instance.

	```lua
	local MyComponent = Component.new({Tag = "MyComponent"})

	function MyComponent:Construct()
		self.SomeData = 32
		self.OtherStuff = "HelloWorld"
	end
	```
]=]

Response:
function Component:Construct()
end


Prompt: -------------------------here

Response:
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
	mouse.Move:connect(function ()
		--local Direction = Tool.Direction.Value
		local Direction = mouse.Hit.p
		local b = head.Position.Y-Direction.Y
		local dist = (head.Position-Direction).magnitude
		local answer = math.asin(b/dist)
		neck.C0=orginalC0*CFrame.fromEulerAnglesXYZ(answer,0,0)
		wait(0.1)
	end)end
else
print("sh")
end
else
print("arms")
end
end

function Unequip(mouse)
if arms ~= nil and torso ~= nil then
local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
if sh ~= nil then
local yes = true
if yes then
yes = false
	neck.C0 = orginalC0

sh[1].Part1 = arms[1]
sh[2].Part1 = arms[2]
welds[1].Parent = nil
welds[2].Parent = nil
end
else
print("sh")
end
else
print("arms")
end
end
Tool.Equipped:connect(Equip)
Tool.Unequipped:connect(Unequip)

function Animate()
arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
	if Tool.AnimateValue.Value == "Shoot" then
		local weld1 = welds[1]
		local weld2 = welds[2]
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
		wait(0.00001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.05, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
		wait(0.00001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.1, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-95), math.rad(-15), 0)
		wait(0.00001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.3, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-110), math.rad(-15), 0)
		wait(0.00001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.35, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-115), math.rad(-15), 0)
		wait(0.00001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
		wait(0.00001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
		Tool.AnimateValue.Value = "None"
	end
	if Tool.AnimateValue.Value == "Reload" then
		local weld1 = welds[1]
		local weld2 = welds[2]
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-95), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-100), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-105), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-110), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-115), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.45, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.9, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.5, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 1, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.55, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 1.1, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.57, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 1.2, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.6, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 1.3, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.6, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
		wait(0.0001)
		weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
		weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
		Tool.AnimateValue.Value = "None"
	end
end

Tool.AnimateValue.Changed:connect(Animate)


Prompt: -- CastBehavior.CosmeticBulletTemplate = CosmeticBullet -- Uncomment if you just want a simple template part and aren't using PartCache

Response:
CastBehavior.CosmeticBulletProvider = CosmeticPartProvider -- Comment out if you aren't using PartCache.

CastBehavior.CosmeticBulletContainer = CosmeticBulletsFolder


Prompt: --------------------[ FIRING FUNCTIONS ]----------------------------------------------

Response:
function lowerSpread()
	if (not loweringSpread) then
		loweringSpread = true
		local Connection = nil
		Connection = RS.Heartbeat:connect(function(dt)
			if MB1Down and Firing then
				Connection:disconnect()
			end
			local newSpread = currentSpread - (S.spreadSettings.Decrease * dt)
			currentSpread = (newSpread < 0 and 0 or newSpread)
			if currentSpread == 0 then
				Connection:disconnect()
			end
		end)
		loweringSpread = false
	end
end

local function autoFire()
	if (not canFire) then return end
	canFire = false

	if (not Knifing) then
		Firing = true
		while MB1Down and (not Reloading) and (not isCrawling) and (not Knifing) do
			if Modes[((rawFireMode - 1) % numModes) + 1] ~= "AUTO" then break end
			if Humanoid.Health == 0 then break end
			if Ammo.Value > 0 then
				Ammo.Value = Ammo.Value - 1
				if Aimed and steadyKeyPressed and S.scopeSettings.unSteadyOnFire then
					steadyKeyPressed = false
					currentSteadyTime = 0
				end
				newMag = false
				fireGun()
			end
			if S.reloadSettings.magIsBullet then
				for _, Mag in pairs(Gun:GetChildren()) do
					if Mag.Name:sub(1, 3) == "Mag" then
						Mag.Transparency = 1
					end
				end
			end
			if Ammo.Value == 0 and S.reloadSettings.autoReload then
				wait(0.2)
				Reload()
			end
			wait(60 / S.roundsPerMin)
		end
	end

	Firing = false
	canFire = true
end

local function semiFire()
	if (not canFire) then return end
	canFire = false

	if (not Knifing) and (not isCrawling) and Humanoid.Health ~= 0 then
		Firing = true
		if Ammo.Value > 0 then
			Ammo.Value = Ammo.Value - 1
			if Aimed and steadyKeyPressed and S.scopeSettings.unSteadyOnFire then
				steadyKeyPressed = false
				currentSteadyTime = 0
			end
			newMag = false
			fireGun()
		end
		if S.reloadSettings.magIsBullet then
			for _, Mag in pairs(Gun:GetChildren()) do
				if Mag.Name:sub(1, 3) == "Mag" then
					Mag.Transparency = 1
				end
			end
		end
		if Ammo.Value == 0 and S.reloadSettings.autoReload then
			wait(0.2)
			Reload()
		end
		wait(60 / S.roundsPerMin)
	end

	Firing = false
	canFire = true
end

local function burstFire()
	if (not canFire) then return end
	canFire = false

	local burstTime = 60 / S.roundsPerMin
	if (not Knifing) and (not isCrawling) then
		Firing = true
		for i = 1, S.burstSettings.Amount do
			if Ammo.Value > 0 then
				Ammo.Value = Ammo.Value - 1
				if Humanoid.Health ~= 0 then
					if Aimed and steadyKeyPressed and S.scopeSettings.unSteadyOnFire then
						steadyKeyPressed = false
						currentSteadyTime = 0
					end
					newMag = false
					fireGun()
				end
			end
			if Ammo.Value == 0 and S.reloadSettings.autoReload then
				wait(0.2)
				Reload()
				break
			end
			wait(S.burstSettings.fireRateBurst and burstTime or S.burstSettings.Time / S.burstSettings.Amount)
		end
	end
	if S.reloadSettings.magIsBullet then
		for _, Mag in pairs(Gun:GetChildren()) do
			if Mag.Name:sub(1, 3) == "Mag" then
				Mag.Transparency = 1
			end
		end
	end

	Firing = false

	wait(S.burstSettings.fireRateBurst and burstTime or S.burstSettings.Wait)

	canFire = true
end

function fireGun()
	local fireSound = Handle:FindFirstChild("FireSound")
	Gun.Bolt.Transparency = 1
Gun.BoltBack.Transparency = 0
	if fireSound then fireSound:Play() end
	----------------------------------------------------------------------------------
	for _ = 1, (S.gunType.Shot and S.ShotAmount or 1) do
		local randSpread1 = RAD(RAND(0, 365))
		local randSpread2 = RAD(RAND(-(baseSpread + currentSpread), baseSpread + currentSpread, 0.01))
		local spreadDir = CFrame.fromAxisAngle(V3(0, 0, 1), randSpread1) * CFANG(randSpread2, 0, 0)

		local originCF = ((Aimed and S.guiScope) and Head.CFrame or Handle.CFrame) * spreadDir
		local bulletDirection = CF(originCF.p, originCF.p + originCF.lookVector).lookVector

		if S.bulletSettings.instantHit then
			local newRay = Ray.new(Main.CFrame.p, bulletDirection * S.bulletSettings.Range)
			local H, P, N = workspace:FindPartOnRayWithIgnoreList(newRay, Ignore)
			local finalP = P
			if H then
				if S.gunType.Explosive then
					if S.explosionSettings.soundId ~= "" then
						local soundPart = Instance.new("Part")
						soundPart.Transparency = 1
						soundPart.Anchored = true
						soundPart.CanCollide = false
						soundPart.Size = V3(1, 1, 1)
						soundPart.CFrame = CFrame.new(P)
						soundPart.Parent = gunIgnore

						local Sound = Instance.new("Sound")
						Sound.Pitch = S.explosionSettings.Pitch
						Sound.SoundId = S.explosionSettings.soundId
						Sound.Volume = S.explosionSettings.Volume
						Sound.Parent = soundPart
						Sound:Play()

						DS:AddItem(soundPart, Sound.TimeLength)
					end
					createBulletImpact:FireServer(H, P, N, bulletDirection, false, gunIgnore, S)
					createShockwave:FireServer(P, S.explosionSettings.Radius, gunIgnore, S)
					local E = Instance.new("Explosion")
					E.BlastPressure = S.explosionSettings.Pressure
					E.BlastRadius = S.explosionSettings.Radius
					E.DestroyJointRadiusPercent = (S.explosionSettings.rangeBasedDamage and 0 or 1)
					E.ExplosionType = S.explosionSettings.Type
					E.Position = P
					E.Hit:connect(function(Obj, Dist)
						if Obj.Name == "Torso" and (not Obj:IsDescendantOf(Char)) then
							if S.explosionSettings.rangeBasedDamage then
								local Dir = (Obj.Position - P).unit
								local expH, _ = workspace:FindPartOnRayWithIgnoreList(
									Ray.new(P - Dir * 0.1, Dir * 999),
									Ignore
								)
								local rayHitHuman = expH:IsDescendantOf(Obj.Parent)
								if (S.explosionSettings.rayCastExplosions and rayHitHuman) or (not S.explosionSettings.rayCastExplosions) then
									local hitHumanoid = findFirstClass(Obj.Parent, "Humanoid")
									if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
										local distFactor = Dist / S.explosionSettings.Radius
										local distInvert = math.max(1 - distFactor,0)
										local newDamage = distInvert * getBaseDamage((P - Main.CFrame.p).magnitude)

										local Tag = Instance.new("ObjectValue")
										Tag.Value = Player
										Tag.Name = "creator"
										Tag.Parent = hitHumanoid
										DS:AddItem(Tag, 0.3)
										hitHumanoid:TakeDamage(newDamage)
										markHit()
									end
								end
							else
								local hitHumanoid = findFirstClass(Obj.Parent, "Humanoid")
								if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
									local Tag = Instance.new("ObjectValue")
									Tag.Value = Player
									Tag.Name = "creator"
									Tag.Parent = hitHumanoid
									DS:AddItem(Tag, 0.3)
									markHit()
								end
							end
						end
					end)
					E.Parent = game.Workspace
				else
					_, finalP = penetrateWall(H, P, bulletDirection, N, {Char, ignoreModel}, 0, (P - Main.CFrame.p).magnitude, nil)
				end
			end
			if S.bulletTrail and S.trailSettings.Transparency ~= 1 then
				createTrail:FireServer(Main.CFrame.p, finalP, gunIgnore, S)
			end
		else
				local shell = Instance.new("Part")
	shell.CFrame = Gun.Chamber.CFrame * CFrame.fromEulerAnglesXYZ(-1.5,0,0)
	shell.Size = Vector3.new(1,1,1)
	shell.BrickColor = BrickColor.new(24)
	shell.Reflectance = .5
	shell.CanCollide = false
	shell.BottomSurface = 0
	shell.TopSurface = 0
	shell.Name = "Shell"
	shell.Velocity = Gun.Chamber.CFrame.lookVector * 30 + Vector3.new(math.random(-10,10),20,math.random(-10,10))
	shell.RotVelocity = Vector3.new(0,200,0)
	local shellmesh = Instance.new("CylinderMesh")
	shellmesh.Scale = Vector3.new(0.1, 0.8, 0.1)
	shellmesh.Parent = shell
	shell.Parent = game.Workspace
	game:GetService("Debris"):addItem(shell,2)

	local shellmesh = Instance.new("SpecialMesh")
	shellmesh.Scale = Vector3.new(0.9,0.9,3)
	shellmesh.MeshId = "http://www.roblox.com/asset/?id=95387759"
	shellmesh.TextureId = "http://www.roblox.com/asset/?id=95387789"
	shellmesh.MeshType = "FileMesh"
	shellmesh.Parent = shell
		end
	end
	function MarkHit()
	spawn(function()
		if Gui_Clone:IsDescendantOf(game) then
			Gui_Clone.HitMarker.Visible = true
			local StartMark = tick()
			LastMark = StartMark
			wait(0.5)
			if LastMark <= StartMark then
				Gui_Clone.HitMarker.Visible = false
			end
		end
	end)
end

	----------------------------------------------------------------------------------

	currentSpread = currentSpread + S.spreadSettings.Increase

	for _, Plugin in pairs(Plugins.Firing) do
		spawn(function()
			Plugin()
		end)
	end

	local backRecoil = RAND(S.recoilSettings.Recoil.Back.Min, S.recoilSettings.Recoil.Back.Max, 0.01) --Get the kickback recoil
	local upRecoil = RAND(S.recoilSettings.Recoil.Up.Min, S.recoilSettings.Recoil.Up.Max, 0.01) --Get the up recoil
	local sideRecoilAlpha = 0
	if lastSideRecoil[1] < 0 and lastSideRecoil[2] < 0 then --This conditional basically makes sure the gun tilt isn't in the same direction for more than 2 shots
		sideRecoilAlpha = RAND(0, 1, 0.1)
	elseif lastSideRecoil[1] > 0 and lastSideRecoil[2] > 0 then
		sideRecoilAlpha = RAND(-1, 0, 0.1)
	else
		sideRecoilAlpha = RAND(-1, 1, 0.1)
	end
	local sideRecoil = numLerp(S.recoilSettings.Recoil.Side.Left, S.recoilSettings.Recoil.Side.Right, sideRecoilAlpha / 2 + 0.5) --Get the side recoil
	local tiltRecoil = numLerp(S.recoilSettings.Recoil.Tilt.Left, S.recoilSettings.Recoil.Tilt.Right, sideRecoilAlpha / 2 + 0.5) --Get the tilt recoil
	local recoilPos = V3(
		0,---sideRecoil,
		0,
		-backRecoil
	) * (Aimed and S.recoilSettings.aimedMultiplier or 1)
	local recoilRot = V3(
		(Aimed and 0 or (-RAD(upRecoil * 10) * (firstShot and S.recoilSettings.firstShotMultiplier or 1))),
		RAD(sideRecoil * 10),
		RAD(tiltRecoil * 10)
	) * (Aimed and S.recoilSettings.aimedMultiplier or 1)
	local camRecoilRot = V3(
		-RAD(sideRecoil * 10),
		RAD(upRecoil * 10) * (firstShot and S.recoilSettings.firstShotMultiplier or 1) * S.recoilSettings.camMultiplier,
		0
	) * (Aimed and S.recoilSettings.aimedMultiplier or 1) * stanceSway
	tweenRecoil(recoilPos, recoilRot, Sine, 0.2)
	tweenCam("Recoil", camRecoilRot, Sine, 0.15 * (firstShot and S.recoilSettings.firstShotMultiplier or 1))

	for _, v in pairs(Main:GetChildren()) do
		if v.Name:sub(1, 7) == "FlashFX" then
			Gun.Bolt.Transparency = 1
Gun.BoltBack.Transparency = 0
			v.Enabled = true
		end
	end

	delay(1 / 20, function()
		tweenRecoil(V3(), V3(), Sine, 0.2)
		tweenCam("Recoil", V3(), Sine, 0.2)
		for _, v in pairs(Main:GetChildren()) do
			if v.Name:sub(1, 7) == "FlashFX" then
	Gun.Bolt.Transparency = 0
Gun.BoltBack.Transparency = 1
				v.Enabled = false
			end
		end
	end)

	updateClipAmmo()
	firstShot = false
	shotCount = shotCount + 1
	lastSideRecoil[(shotCount % 2) + 1] = sideRecoilAlpha
end

function markHit()
	spawn(function()
		if mainGUI:IsDescendantOf(game) then
			hitMarker.Visible = true
			local startMark = tick()
			hitMarker.lastMark.Value = startMark

			wait(0.5)

			if hitMarker.lastMark.Value <= startMark then
				hitMarker.Visible = false
			end
		end
	end)
end


Prompt:
--[[
Notes:
- The commission will take up to 30 days of pending before the game owner is able to use it.
- Also note that UGC creators have the option to disable in-game commissions, so you will not be able to earn commissions on some UGC items.
- Only the game creator will earn the commission.
--]]


Prompt:
--[[

	CameraShaker.CameraShakeInstance

	cameraShaker = CameraShaker.new(renderPriority, callbackFunction)

	CameraShaker:Start()
	CameraShaker:Stop()
	CameraShaker:StopSustained([fadeOutTime])
	CameraShaker:Shake(shakeInstance)
	CameraShaker:ShakeSustain(shakeInstance)
	CameraShaker:ShakeOnce(magnitude, roughness [, fadeInTime, fadeOutTime, posInfluence, rotInfluence])
	CameraShaker:StartShake(magnitude, roughness [, fadeInTime, posInfluence, rotInfluence])

	EXAMPLE:

		local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
			camera.CFrame = playerCFrame * shakeCFrame
		end)

		camShake:Start()

		-- Explosion shake:
		camShake:Shake(CameraShaker.Presets.Explosion)

		wait(1)

		-- Custom shake:
		camShake:ShakeOnce(3, 1, 0.2, 1.5)

		-- Sustained shake:
		camShake:ShakeSustain(CameraShaker.Presets.Earthquake)

		-- Stop all sustained shakes:
		camShake:StopSustained(1) -- Argument is the fadeout time (defaults to the same as fadein time if not supplied)

		-- Stop only one sustained shake:
		shakeInstance = camShake:ShakeSustain(CameraShaker.Presets.Earthquake)
		wait(2)
		shakeInstance:StartFadeOut(1) -- Argument is the fadeout time

	NOTE:

		This was based entirely on the EZ Camera Shake asset for Unity3D. I was given written
		permission by the developer, Road Turtle Games, to port this to Roblox.

		Original asset link: https://assetstore.unity.com/packages/tools/camera/ez-camera-shake-33148

		GitHub repository: https://github.com/Sleitnick/RbxCameraShaker

--]]

Response:
local CameraShaker = {}
CameraShaker.__index = CameraShaker

local profileBegin = debug.profilebegin
local profileEnd = debug.profileend
local profileTag = "CameraShakerUpdate"

local V3 = Vector3.new
local CF = CFrame.new
local ANG = CFrame.Angles
local RAD = math.rad
local v3Zero = V3()

local CameraShakeInstance = require(script.CameraShakeInstance)
local CameraShakeState = CameraShakeInstance.CameraShakeState

local defaultPosInfluence = V3(0.15, 0.15, 0.15)
local defaultRotInfluence = V3(1, 1, 1)

CameraShaker.CameraShakeInstance = CameraShakeInstance
CameraShaker.Presets = require(script.CameraShakePresets)

function CameraShaker.new(renderPriority: number, callback: (camCFrame: CFrame) -> ())
	assert(type(renderPriority) == "number", "RenderPriority must be a number (e.g.: Enum.RenderPriority.Camera.Value)")
	assert(type(callback) == "function", "Callback must be a function")

	local self = setmetatable({
		_running = false;
		_renderName = "CameraShaker";
		_renderPriority = renderPriority;
		_posAddShake = v3Zero;
		_rotAddShake = v3Zero;
		_camShakeInstances = {};
		_removeInstances = {};
		_callback = callback;
	}, CameraShaker)

	return self

end

function CameraShaker:Start()
	if (self._running) then return end
	self._running = true
	local callback = self._callback
	game:GetService("RunService"):BindToRenderStep(self._renderName, self._renderPriority, function(dt)
		profileBegin(profileTag)
		local cf = self:Update(dt)
		profileEnd()
		callback(cf)
	end)
end

function CameraShaker:Stop()
	if (not self._running) then return end
	game:GetService("RunService"):UnbindFromRenderStep(self._renderName)
	self._running = false
end

function CameraShaker:StopSustained(duration: number)
	for _,c in pairs(self._camShakeInstances) do
		if (c.fadeOutDuration == 0) then
			c:StartFadeOut(duration or c.fadeInDuration)
		end
	end
end

function CameraShaker:Update(dt: number)

	local posAddShake = v3Zero
	local rotAddShake = v3Zero

	local instances = self._camShakeInstances

	-- Update all instances:
	for i = 1,#instances do

		local c = instances[i]
		local state = c:GetState()

		if (state == CameraShakeState.Inactive and c.DeleteOnInactive) then
			self._removeInstances[#self._removeInstances + 1] = i
		elseif (state ~= CameraShakeState.Inactive) then
			local shake = c:UpdateShake(dt)
			posAddShake = posAddShake + (shake * c.PositionInfluence)
			rotAddShake = rotAddShake + (shake * c.RotationInfluence)
		end

	end

	-- Remove dead instances:
	for i = #self._removeInstances,1,-1 do
		local instIndex = self._removeInstances[i]
		table.remove(instances, instIndex)
		self._removeInstances[i] = nil
	end

	return CF(posAddShake) *
			ANG(0, RAD(rotAddShake.Y), 0) *
			ANG(RAD(rotAddShake.X), 0, RAD(rotAddShake.Z))

end

function CameraShaker:Shake(shakeInstance)
	assert(type(shakeInstance) == "table" and shakeInstance._camShakeInstance, "ShakeInstance must be of type CameraShakeInstance")
	self._camShakeInstances[#self._camShakeInstances + 1] = shakeInstance
	return shakeInstance
end

function CameraShaker:ShakeSustain(shakeInstance)
	assert(type(shakeInstance) == "table" and shakeInstance._camShakeInstance, "ShakeInstance must be of type CameraShakeInstance")
	self._camShakeInstances[#self._camShakeInstances + 1] = shakeInstance
	shakeInstance:StartFadeIn(shakeInstance.fadeInDuration)
	return shakeInstance
end

function CameraShaker:ShakeOnce(magnitude: number, roughness: number, fadeInTime: number, fadeOutTime: number, posInfluence: Vector3, rotInfluence: Vector3)
	local shakeInstance = CameraShakeInstance.new(magnitude, roughness, fadeInTime, fadeOutTime)
	shakeInstance.PositionInfluence = (typeof(posInfluence) == "Vector3" and posInfluence or defaultPosInfluence)
	shakeInstance.RotationInfluence = (typeof(rotInfluence) == "Vector3" and rotInfluence or defaultRotInfluence)
	self._camShakeInstances[#self._camShakeInstances + 1] = shakeInstance
	return shakeInstance
end

function CameraShaker:StartShake(magnitude: number, roughness: number, fadeInTime: number, posInfluence: Vector3, rotInfluence: Vector3)
	local shakeInstance = CameraShakeInstance.new(magnitude, roughness, fadeInTime)
	shakeInstance.PositionInfluence = (typeof(posInfluence) == "Vector3" and posInfluence or defaultPosInfluence)
	shakeInstance.RotationInfluence = (typeof(rotInfluence) == "Vector3" and rotInfluence or defaultRotInfluence)
	shakeInstance:StartFadeIn(fadeInTime)
	self._camShakeInstances[#self._camShakeInstances + 1] = shakeInstance
	return shakeInstance
end

return CameraShaker


Prompt: -- Listeners

Response:
SpawnSegway.OnServerEvent:connect(function(Player,Character,MaxSpeed,TurnSpeed,Tool,SpawnedSegway,Color)
	Functions.SpawnSegway(Player,Character,MaxSpeed,TurnSpeed,Tool,SpawnedSegway,Color)
end)

ConfigTool.OnServerEvent:connect(function(Player,Transparency,Tool,ShouldColor,Color)
	Functions.ConfigTool(Transparency,Tool,ShouldColor,Color)
end)

DestroySegway.OnServerEvent:connect(function(Player,Character,SpawnedSegway)
	Functions.DestroySegway(Character,SpawnedSegway)
end)

PlaySound.OnServerEvent:connect(function(Player,Sound,Pitch,Volume)
	Functions.PlaySound(Sound,Pitch,Volume)
end)

StopSound.OnServerEvent:connect(function(Player,Sound,Volume)
	Functions.StopSound(Sound,Volume)
end)

AnchorSegway.OnServerEvent:connect(function(Player,PrimaryPart,Anchored)
	Functions.AnchorPart(PrimaryPart,Anchored)
end)

UndoTags.OnServerEvent:connect(function(Player,SegwayObject,WeldObject,Thruster,TiltMotor)
	Functions.UndoTags(SegwayObject,WeldObject,Thruster,TiltMotor)
end)

UndoHasWelded.OnServerEvent:connect(function(Player,SeaterObject)
	Functions.UndoHasWelded(SeaterObject)
end)

function DeleteWelds.OnServerInvoke(Player,Part)
	Functions.DeleteWelds(Part)
	return true
end

ConfigHumanoid.OnServerEvent:connect(function(Player,Humanoid,PlatformStand,Jump,AutoRotate)
	Functions.ConfigHumanoid(Player.Character,Humanoid,PlatformStand,Jump,AutoRotate)
end)

ConfigLights.OnServerEvent:connect(function(Player,Transparency,Color,Bool,Material,Lights,Notifiers)
	Functions.ConfigLights(Transparency,Color,Bool,Material,Lights,Notifiers)
end)


Prompt: --[[ Module functions ]]

Response:
--
function Invisicam:LimbBehavior(castPoints)
	for limb, _ in pairs(self.trackedLimbs) do
		castPoints[#castPoints + 1] = limb.Position
	end
end

function Invisicam:MoveBehavior(castPoints)
	for i = 1, MOVE_CASTS do
		local position: Vector3, velocity: Vector3 = self.humanoidRootPart.Position, self.humanoidRootPart.Velocity
		local horizontalSpeed: number = Vector3.new(velocity.X, 0, velocity.Z).Magnitude / 2
		local offsetVector: Vector3 = (i - 1) * self.humanoidRootPart.CFrame.lookVector :: Vector3 * horizontalSpeed
		castPoints[#castPoints + 1] = position + offsetVector
	end
end

function Invisicam:CornerBehavior(castPoints)
	local cframe: CFrame = self.humanoidRootPart.CFrame
	local centerPoint: Vector3 = cframe.p
	local rotation = cframe - centerPoint
	local halfSize = self.char:GetExtentsSize() / 2 --NOTE: Doesn't update w/ limb animations
	castPoints[#castPoints + 1] = centerPoint
	for i = 1, #CORNER_FACTORS do
		castPoints[#castPoints + 1] = centerPoint + (rotation * (halfSize * CORNER_FACTORS[i]))
	end
end

function Invisicam:CircleBehavior(castPoints)
	local cframe: CFrame
	if self.mode == MODE.CIRCLE1 then
		cframe = self.humanoidRootPart.CFrame
	else
		local camCFrame: CFrame = self.camera.CoordinateFrame
		cframe = camCFrame - camCFrame.p + self.humanoidRootPart.Position
	end
	castPoints[#castPoints + 1] = cframe.p
	for i = 0, CIRCLE_CASTS - 1 do
		local angle = (2 * math.pi / CIRCLE_CASTS) * i
		local offset = 3 * Vector3.new(math.cos(angle), math.sin(angle), 0)
		castPoints[#castPoints + 1] = cframe * offset
	end
end

function Invisicam:LimbMoveBehavior(castPoints)
	self:LimbBehavior(castPoints)
	self:MoveBehavior(castPoints)
end

function Invisicam:CharacterOutlineBehavior(castPoints)
	local torsoUp = self.torsoPart.CFrame.upVector.unit
	local torsoRight = self.torsoPart.CFrame.rightVector.unit

	-- Torso cross of points for interior coverage
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p + torsoUp
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p - torsoUp
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p + torsoRight
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p - torsoRight
	if self.headPart then
		castPoints[#castPoints + 1] = self.headPart.CFrame.p
	end

	local cframe = CFrame.new(ZERO_VECTOR3,Vector3.new(self.camera.CoordinateFrame.lookVector.X,0,self.camera.CoordinateFrame.lookVector.Z))
	local centerPoint = (self.torsoPart and self.torsoPart.Position or self.humanoidRootPart.Position)

	local partsWhitelist = {self.torsoPart}
	if self.headPart then
		partsWhitelist[#partsWhitelist + 1] = self.headPart
	end

	for i = 1, CHAR_OUTLINE_CASTS do
		local angle = (2 * math.pi * i / CHAR_OUTLINE_CASTS)
		local offset = cframe * (3 * Vector3.new(math.cos(angle), math.sin(angle), 0))

		offset = Vector3.new(offset.X, math.max(offset.Y, -2.25), offset.Z)

		local ray = Ray.new(centerPoint + offset, -3 * offset)
		local hit, hitPoint = game.Workspace:FindPartOnRayWithWhitelist(ray, partsWhitelist, false, false)

		if hit then
			-- Use hit point as the cast point, but nudge it slightly inside the character so that bumping up against
			-- walls is less likely to cause a transparency glitch
			castPoints[#castPoints + 1] = hitPoint + 0.2 * (centerPoint - hitPoint).unit
		end
	end
end

function Invisicam:SmartCircleBehavior(castPoints)
	local torsoUp = self.torsoPart.CFrame.upVector.unit
	local torsoRight = self.torsoPart.CFrame.rightVector.unit

	-- SMART_CIRCLE mode includes rays to head and 5 to the torso.
	-- Hands, arms, legs and feet are not included since they
	-- are not canCollide and can therefore go inside of parts
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p + torsoUp
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p - torsoUp
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p + torsoRight
	castPoints[#castPoints + 1] = self.torsoPart.CFrame.p - torsoRight
	if self.headPart then
		castPoints[#castPoints + 1] = self.headPart.CFrame.p
	end

	local cameraOrientation = self.camera.CFrame - self.camera.CFrame.p
	local torsoPoint = Vector3.new(0,0.5,0) + (self.torsoPart and self.torsoPart.Position or self.humanoidRootPart.Position)
	local radius = 2.5

	-- This loop first calculates points in a circle of radius 2.5 around the torso of the character, in the
	-- plane orthogonal to the camera's lookVector. Each point is then raycast to, to determine if it is within
	-- the free space surrounding the player (not inside anything). Two iterations are done to adjust points that
	-- are inside parts, to try to move them to valid locations that are still on their camera ray, so that the
	-- circle remains circular from the camera's perspective, but does not cast rays into walls or parts that are
	-- behind, below or beside the character and not really obstructing view of the character. This minimizes
	-- the undesirable situation where the character walks up to an exterior wall and it is made invisible even
	-- though it is behind the character.
	for i = 1, SMART_CIRCLE_CASTS do
		local angle = SMART_CIRCLE_INCREMENT * i - 0.5 * math.pi
		local offset = radius * Vector3.new(math.cos(angle), math.sin(angle), 0)
		local circlePoint = torsoPoint + cameraOrientation * offset

		-- Vector from camera to point on the circle being tested
		local vp = circlePoint - self.camera.CFrame.p

		local ray = Ray.new(torsoPoint, circlePoint - torsoPoint)
		local hit, hp, hitNormal = game.Workspace:FindPartOnRayWithIgnoreList(ray, {self.char}, false, false )
		local castPoint = circlePoint

		if hit then
			local hprime = hp + 0.1 * hitNormal.unit -- Slightly offset hit point from the hit surface
			local v0 = hprime - torsoPoint -- Vector from torso to offset hit point

			local perp = (v0:Cross(vp)).unit

			-- Vector from the offset hit point, along the hit surface
			local v1 = (perp:Cross(hitNormal)).unit

			-- Vector from camera to offset hit
			local vprime = (hprime - self.camera.CFrame.p).unit

			-- This dot product checks to see if the vector along the hit surface would hit the correct
			-- side of the invisicam cone, or if it would cross the camera look vector and hit the wrong side
			if ( v0.unit:Dot(-v1) < v0.unit:Dot(vprime)) then
				castPoint = RayIntersection(hprime, v1, circlePoint, vp)

				if castPoint.Magnitude > 0 then
					local ray = Ray.new(hprime, castPoint - hprime)
					local hit, hitPoint, hitNormal = game.Workspace:FindPartOnRayWithIgnoreList(ray, {self.char}, false, false )

					if hit then
						local hprime2 = hitPoint + 0.1 * hitNormal.unit
						castPoint = hprime2
					end
				else
					castPoint = hprime
				end
			else
				castPoint = hprime
			end

			local ray = Ray.new(torsoPoint, (castPoint - torsoPoint))
			local hit, hitPoint, hitNormal = game.Workspace:FindPartOnRayWithIgnoreList(ray, {self.char}, false, false )

			if hit then
				local castPoint2 = hitPoint - 0.1 * (castPoint - torsoPoint).unit
				castPoint = castPoint2
			end
		end

		castPoints[#castPoints + 1] = castPoint
	end
end

function Invisicam:CheckTorsoReference()
	if self.char then
		self.torsoPart = self.char:FindFirstChild("Torso")
		if not self.torsoPart then
			self.torsoPart = self.char:FindFirstChild("UpperTorso")
			if not self.torsoPart then
				self.torsoPart = self.char:FindFirstChild("HumanoidRootPart")
			end
		end

		self.headPart = self.char:FindFirstChild("Head")
	end
end

function Invisicam:CharacterAdded(char: Model, player: Player)
	-- We only want the LocalPlayer's character
	if player~=PlayersService.LocalPlayer then return end

	if self.childAddedConn then
		self.childAddedConn:Disconnect()
		self.childAddedConn = nil
	end
	if self.childRemovedConn then
		self.childRemovedConn:Disconnect()
		self.childRemovedConn = nil
	end

	self.char = char

	self.trackedLimbs = {}
	local function childAdded(child)
		if child:IsA("BasePart") then
			if LIMB_TRACKING_SET[child.Name] then
				self.trackedLimbs[child] = true
			end

			if child.Name == "Torso" or child.Name == "UpperTorso" then
				self.torsoPart = child
			end

			if child.Name == "Head" then
				self.headPart = child
			end
		end
	end

	local function childRemoved(child)
		self.trackedLimbs[child] = nil

		-- If removed/replaced part is 'Torso' or 'UpperTorso' double check that we still have a TorsoPart to use
		self:CheckTorsoReference()
	end

	self.childAddedConn = char.ChildAdded:Connect(childAdded)
	self.childRemovedConn = char.ChildRemoved:Connect(childRemoved)
	for _, child in pairs(self.char:GetChildren()) do
		childAdded(child)
	end
end

function Invisicam:SetMode(newMode: number)
	AssertTypes(newMode, 'number')
	for _, modeNum in pairs(MODE) do
		if modeNum == newMode then
			self.mode = newMode
			self.behaviorFunction = self.behaviors[self.mode]
			return
		end
	end
	error("Invalid mode number")
end

function Invisicam:GetObscuredParts()
	return self.savedHits
end


Prompt:
--[=[
	Utility functions to observe the state of Roblox. This is a very powerful way to query
	Roblox's state.

	:::tip
	Use RxInstanceUtils to program streaming enabled games, and make it easy to debug. This API surface
	lets you use Roblox as a source-of-truth which is very valuable.
	:::

	@class RxInstanceUtils
]=]

Response:
local require = require(script.Parent.loader).load(script)

local Brio = require("Brio")
local Maid = require("Maid")
local Observable = require("Observable")
local Rx = require("Rx")
local Symbol = require("Symbol")

local UNSET_VALUE = Symbol.named("unsetValue")

local RxInstanceUtils = {}