Prompt: --Optimization--

Response:
local rad = math.rad
local random = math.random
local NewCFrame = CFrame.new
local Angles = CFrame.Angles
local NewVector = Vector3.new
local CFLookAt = CFrame.lookAt
local NewInstance = Instance.new

local function IsHeadAccessory(Handle)
	if Handle:FindFirstChild("HatAttachment") or Handle:FindFirstChild("HairAttachment") or Handle:FindFirstChild("NeckAttachment") or Handle:FindFirstChild("FaceFrontAttachment") then
		return true
	else
		return false
	end
end

local function OnLengthChanged(Cast, LastPoint, Direction, Length, Velocity, Bullet)
	if Bullet then
		local BulletLength = Bullet.Size.Z/2
		local Offset = NewCFrame(0,0,-(Length - BulletLength))
		Bullet.CFrame = CFLookAt(LastPoint, LastPoint + Direction):ToWorldSpace(Offset)
	end
end

local function OnHit(Cast, Result, Velocity, Bullet)
	local HitCoroutine = coroutine.create(function()
		local Hit = Result.Instance
		local Damage = random(MinimumDamage,MaximumDamage)

		if Hit.Parent:IsA("Model") and not core.isAlly(Hit.Parent) then
			if Hit.Parent:FindFirstChild("Humanoid") then
				local Humanoid = Hit:FindFirstAncestorWhichIsA("Model"):FindFirstChild("Humanoid")

				if Hit.Name == "Head" then
					Humanoid:TakeDamage(Damage * headshotmultiplier)
				else
					Humanoid:TakeDamage(Damage)
				end

				local HitSound = NewInstance("Sound",Hit)
				HitSound.PlayOnRemove = true
				HitSound.SoundId = HitFleshSound
				HitSound:Destroy()
			else
				local newBulletHole = combat.getBulletHole()
				newBulletHole.CFrame = NewCFrame(Result.Position,Result.Position + Result.Normal)

				for i = 1, random(2,3) do
					local chunk = NewInstance("Part")
					chunk.Color = Result.Instance.Color
					chunk.Material = Result.Instance.Material
					local size = random(5)/20
					chunk.Size = NewVector(size,size,size)
					chunk.CFrame = NewCFrame(Result.Position)
					chunk.Anchored = false
					chunk.Velocity = NewVector(random(-20,20),random(10,20),random(-20,20))
					chunk.Parent = workspace.IgnoreFolder
					chunk:SetNetworkOwner(nil)

					debrisService:AddItem(chunk,1)
				end

				local soundattachment = NewInstance("Part",workspace.IgnoreFolder)
				soundattachment.Size = NewVector(0,0,0)
				soundattachment.CanCollide = false
				soundattachment.CFrame = NewCFrame(Result.Position)
				soundattachment.Anchored = true

				local HitSound = NewInstance("Sound",soundattachment)
				HitSound.SoundId = HitWallSounds[random(1,#HitWallSounds)]
				HitSound.Volume = 1
				HitSound:Play()

				debrisService:AddItem(soundattachment,1.5)
				debrisService:AddItem(newBulletHole,5)
			end
		elseif Hit.Parent:IsA("Accessory") then
			local IsAHeadAccessory = IsHeadAccessory(Hit)
			if Hit.Parent.Parent:IsA("Model") and not core.isAlly(Hit.Parent.Parent) then
				local Model = Hit.Parent.Parent
				if Model:FindFirstChild("Humanoid") then
					if IsAHeadAccessory then
						Model.Humanoid:TakeDamage(Damage * headshotmultiplier)
					else
						Model.Humanoid:TakeDamage(Damage)
					end

					local HitSound = NewInstance("Sound",Hit)
					HitSound.PlayOnRemove = true
					HitSound.SoundId = HitFleshSound
					HitSound:Destroy()

				end
			end
		end

	end)

	coroutine.resume(HitCoroutine)

	debrisService:AddItem(Bullet,0.7)

	if Bullet:FindFirstChild("Whiz") then
		Bullet.Whiz:Stop()
	end
end

function combat.getBulletHole()
	local c = game.ServerStorage:WaitForChild("Hole"):Clone()
	c.Parent = workspace.IgnoreFolder

	return c
end

function combat.getBullet()
	local c = game.ServerStorage:WaitForChild("Bullet"):Clone()
	c.Parent = workspace.IgnoreFolder

	return c
end

function combat.getCase()
	local c = game.ServerStorage:WaitForChild("Case"):Clone()
	c.Parent = workspace.IgnoreFolder

	return c
end

function pushBullet(bullet)
	-- replaced all the code in this function

	local origin = barrel.WorldPosition
	local direction = (NewCFrame(origin,(barrel.WorldCFrame * NewCFrame(0,0,-5)).Position) * Angles(rad(random(-spread,spread)),rad(random(-spread,spread)),rad(random(-spread,spread)))).LookVector

	local NewVelocity = direction * bulletspeed

	NewCaster:Fire(origin, direction, NewVelocity, Behaviour)

	local MaxLength = 0 -- value starts at zero and works its way up to the maximum distance as the bullet travels (used to detect how far the cosmetic bullet travels before being destroyed if it reaches max distance)

	NewCaster.LengthChanged:Connect(function(Cast,LastPoint,NewDirection,Length,NewVelocity,Bullet)
		OnLengthChanged(Cast, LastPoint, NewDirection, Length, NewVelocity, Bullet)
		MaxLength += Length

		if MaxLength >= maxdistance and Bullet ~= nil then
			Bullet:Destroy()
		end
	end)

	NewCaster.RayHit:Connect(OnHit)
end

local flashIndex = 1
function combat.shoot(target)
	if status:get("weaponCool") and not status:get("reloading") then
		status:set("weaponCool",false)

		local shot
		if core.checkDist(target,myRoot) > 60 then
			shot = 1
		else
			shot = burstamount
		end

		if not fullauto then
			for i = 1, shot do
				if myHuman.Health <= 0 or target.Parent.Humanoid.Health <= 0 then break end

				if core.checkDist(myRoot,target) < 7 then break end

				wait(firerate)
				status:set("mag",status:get("mag")-1)

				--flash:Emit(1)
				local FlashCoroutine = coroutine.create(function()
					barrel.MuzzleFlash:Emit(20)
					barrel.Dust:Emit(40)
					lightFlash.Enabled = true
					wait(0.1)
					lightFlash.Enabled = false
				end)

				coroutine.resume(FlashCoroutine)
				--bullet.CFrame = m4.CFrame * NewCFrame(0,0.2,-2.5) --z: 0.5

				if shotgunpellets > 1 then
					for i = 1,shotgunpellets,1 do
						spawn(function()
							local bullet = combat.getBullet()
							pushBullet(bullet)
							bullet:Destroy()
						end)
					end
				else
					local bullet = combat.getBullet()
					pushBullet(bullet)
					bullet:Destroy()
				end

				local case = combat.getCase()
				case.CFrame = chamber.WorldCFrame
				case.Velocity = case.CFrame.RightVector * -20 * NewVector(1,-3,1)
				case:SetNetworkOwner(nil)
				core.spawn(function()
					wait(0.05)
					case.CanCollide = true
					wait(2)
					case:Destroy()
				end)

				fireSound:Play()

				--Kick
				local original = m4.HingeAttach1.Position
				m4.HingeAttach1.Position = original - NewVector(0,0,0.2)
				tweenService:Create(m4.HingeAttach1, TweenInfo.new(0.1),{Position = original}):Play()

			end
		else
			local Params = RaycastParams.new()
			Params.FilterType = Enum.RaycastFilterType.Blacklist
			Params.FilterDescendantsInstances = {marine}

			local Success,Error = pcall(function() -- gonna make sure if something strange happens the whole script wont freeze
				for i = 1, status:get("mag") do
					if myHuman.Health <= 0 or target.Parent.Humanoid.Health <= 0 then break end

					local cansee = false
					local eyesight = workspace:Raycast(myHead.Position,(target.Parent.Head.Position - myHead.Position).Unit * detectionrange,Params)
					pcall(function()
						if eyesight.Instance and eyesight.Instance:IsDescendantOf(target.Parent) then
							cansee = true
						end
					end)

					if not cansee then break end

					wait(firerate)
					status:set("mag",status:get("mag")-1)

					--flash:Emit(1)
					local FlashCoroutine = coroutine.create(function()
						barrel.MuzzleFlash:Emit(20)
						barrel.Dust:Emit(40)
						lightFlash.Enabled = true
						wait(0.1)
						lightFlash.Enabled = false
					end)

					coroutine.resume(FlashCoroutine)

					if shotgunpellets > 1 then
						for i = 1,shotgunpellets,1 do
							spawn(function()
								local bullet = combat.getBullet()
								pushBullet(bullet)
								bullet:Destroy()
							end)
						end
					else
						local bullet = combat.getBullet()
						pushBullet(bullet)
						bullet:Destroy()
					end

					local case = combat.getCase()
					case.CFrame = chamber.WorldCFrame
					case.Velocity = case.CFrame.RightVector * -20 * NewVector(1,-3,1)
					core.spawn(function()
						wait(0.05)
						case.CanCollide = true
						wait(2)
						case:Destroy()
					end)

					fireSound:Play()

					--Kick
					local original = m4.HingeAttach1.Position
					m4.HingeAttach1.Position = original - NewVector(0,0,0.2)
					tweenService:Create(m4.HingeAttach1, TweenInfo.new(0.1),{Position = original}):Play()

				end
			end)

			if not Success then
				warn(Error)
			end
		end
		if status:get("mag") <= 0 then
			wait(delaybeforereloading)
			actions.reload()
		end

		--New thread here before
		wait(mySettings.M4.Delay.Value)
		status:set("weaponCool",true)
	end
end

function combat.throwGrenade(target)
	if status:get("weaponCool") and status:get("grenadeCool") then
		status:set("weaponCool",false)
		status:set("grenadeCool",false)
		actions.yieldWeapons()

		local g = marine.Grenade:Clone()
		g.Boom.PlayOnRemove = true
		g.Parent = workspace
		g.CanCollide = true
		g.CFrame = marine["Right Arm"].CFrame * NewCFrame(0,-1.3,0) * Angles(0,0,rad(90))
		g:SetNetworkOwner(nil)
		debrisService:AddItem(g,5)

		marine.Grenade.Transparency = 1

		local w = NewInstance("WeldConstraint",g)
		w.Part0 = marine["Right Arm"]
		w.Part1 = g

		throwAnimation:Play()
		marine.Grenade.Pin:Play()

		--Rotate and throw
		myHuman.AutoRotate = false
		for i=1,4 do
			wait(0.1)
			myRoot.CFrame = CFLookAt(NewVector(myRoot.Position.X,myRoot.Position.Y,myRoot.Position.Z),NewVector(target.Position.X,myRoot.Position.Y,target.Position.Z))
		end
		myHuman.AutoRotate = true

		if myHuman.Health <= 0 then
			return
		end

		throwAnimation:Stop()

		w.Part1 = nil
		local targetPos = target.Position + (target.Velocity)
		troubleshoot.mark(targetPos)
		local dist = core.checkDist(myRoot,target)
		local aimCFrame = CFLookAt(myRoot.Position,targetPos)
		--g.Velocity = (aimCFrame.LookVector + NewVector(0,1.1,0)) * NewVector(dist,dist*1.5,dist)
		g.Velocity = (myRoot.CFrame.LookVector + NewVector(0,1,0)) * NewVector(dist,dist*1.5,dist)

		--Wait until grenade is thrown before it can be primed
		touched = g.Touched:Connect(function(obj)
			if not obj:IsDescendantOf(marine) then
				touched:Disconnect()
				g.HitWall:Play()
				wait(0.5)
				local x = NewInstance("Explosion",workspace)
				x.Position = g.Position
				x.BlastRadius = 16
				x.BlastPressure = 0
				x.Hit:Connect(function(obj,dist)
					local human = obj.Parent:FindFirstChild("Humanoid")
					if human then
						core.applyDamage(human,20-dist)
					end
				end)
				g:Destroy()
				debrisService:AddItem(x,2)
			end
		end)

		local attach0 = g.Attach0
		local attach1 = g.Attach1
		local t = NewInstance("Trail",g)
		t.Attachment0 = attach0
		t.Attachment1 = attach1
		t.Lifetime = 0.5
		t.Color = ColorSequence.new(Color3.fromRGB(150,150,150))
		t.WidthScale = NumberSequence.new(1,0)

		core.spawn(function()
			wait(1)
			status:set("weaponCool",true)
			wait(5)
			status:set("grenadeCool",true)
			marine.Grenade.Transparency = 0
		end)
	end
end

local knife = marine.Knife
function combat.stab()

	local canStab = false
	for i,v in pairs(status:get("currentTarget").Parent:GetChildren()) do
		if v:IsA("BasePart") and core.checkDist(v,myRoot) < 7 then
			canStab = true
		end
	end
	if canStab then
		myHuman:MoveTo(status:get("currentTarget").Position)

		knife.Stab:Play()
		knife.Attack:Play()

		if random(2) == 1 then
			stabAnimation:Play(0.1,1,2)
		else
			stabPunchAnimation:Play()
		end

		local human = status:get("currentTarget").Parent.Humanoid
		core.applyDamage(human,random(MinimumDamage,MaximumDamage))
		if human.Health <= 0 then
			targeting.findTarget()
		end

		--stabAnimation.Stopped:Wait()
		wait(0.5)
	else
		wait(0.2)
	end
end

function combat.checkCluster(target)
	--Check for nearby allies
	for i,v in ipairs(status:get("activeAllies")) do
		if core.checkDist(target,v) < 30 then
			return false
		end
	end
	--Check if enemies are paired close together
	for i,v in ipairs(status:get("potentialTargets")) do
		if v ~= target then
			if core.checkDist(target,v) < 15 then
				return true
			end
		end
	end
	return false
end

return combat


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_name = "", -- [string] -- DataStore name
				_profile_template = {} / nil, -- [table / nil]
				_global_data_store = global_data_store, -- [GlobalDataStore] -- Object returned by DataStoreService:GetDataStore(_profile_store_name)

				_loaded_profiles = {
					[profile_key] = {
						Data = {}, -- [table] -- Loaded once after ProfileStore:LoadProfileAsync() finishes
						MetaData = {}, -- [table] -- Updated with every auto-save
						GlobalUpdates = {, -- [GlobalUpdates]
							_updates_latest = {}, -- [table] {update_index, {{update_id, version_id, update_locked, update_data}, ...}}
							_pending_update_lock = {update_id, ...} / nil, -- [table / nil]
							_pending_update_clear = {update_id, ...} / nil, -- [table / nil]

							_new_active_update_listeners = {listener, ...} / nil, -- [table / nil]
							_new_locked_update_listeners = {listener, ...} / nil, -- [table / nil]

							_profile = Profile / nil, -- [Profile / nil]

							_update_handler_mode = true / nil, -- [bool / nil]
						}

						_profile_store = ProfileStore, -- [ProfileStore]
						_profile_key = "", -- [string]

						_release_listeners = {listener, ...} / nil, -- [table / nil]

						_view_mode = true / nil, -- [bool / nil]

						_load_timestamp = os.clock(),

						_is_user_mock = false, -- ProfileStore.Mock
					},
					...
				},
				_profile_load_jobs = {[profile_key] = {load_id, loaded_data}, ...},

				_mock_loaded_profiles = {[profile_key] = Profile, ...},
				_mock_profile_load_jobs = {[profile_key] = {load_id, loaded_data}, ...},
				_is_pending = false, -- Waiting for live access check
			},
			...
		--]]
	},

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

	_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:
--[[
	If a Repair Kit touches the system, increase the health - if it's a monster, decrease its health.
]]

Response:
local function onTouched(self, otherPart)
	if otherPart.Anchored then
		return
	end

	if CollectionService:HasTag(otherPart, Constants.Tag.Tool.RepairKit) then
		if self._health ~= self._maxHealth then
			otherPart:Destroy()
			self:incrementHealth(DEFAULT_TOOLKIT_HEALING_AMOUNT)
		end
	elseif CollectionService:HasTag(otherPart, Constants.Tag.Monster) and not self._monsterDebounce then
		self._monsterDebounce = true

		self:incrementHealth(-MONSTER_DAMAGE)

		delay(
			MONSTER_DEBOUNCE_TIME,
			function()
				self._monsterDebounce = false
			end
		)
	end
end

local BaseSystem = ClassUtils.makeClass(script.Name)


Prompt: -- Services

Response:
local RbxUtility = LoadLibrary("RbxUtility")
local Create = RbxUtility.Create


Response:
	if hit.Parent:findFirstChild("Humanoid") ~= nil then
		local target1 = "RightLowerArm"
		local target2 = "RightLowerArm2"
		if hit.Parent:findFirstChild(target2) == nil then
			local g = script.Parent.Parent[target2]:clone()
			g.Parent = hit.Parent
			local C = g:GetChildren()
			for i=1, #C do
				if C[i].className == "UnionOperation" or C[i].className =="Part" or C[i].className == "WedgePart" or C[i].className == "MeshPart" then
					local W = Instance.new("Weld")
					W.Part0 = g.Middle
					W.Part1 = C[i]
					local CJ = CFrame.new(g.Middle.Position)
					local C0 = g.Middle.CFrame:inverse()*CJ
					local C1 = C[i].CFrame:inverse()*CJ
					W.C0 = C0
					W.C1 = C1
					W.Parent = g.Middle
				end
				local Y = Instance.new("Weld")
				Y.Part0 = hit.Parent[target1]
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
			end

		local h = g:GetChildren()
		for i = 1, # h do
			h[i].Anchored = false
			h[i].CanCollide = false
		end
	end
	end


Prompt: -- Styles

Response:
local function CreateColor3(r, g, b) return Color3.new(r/255,g/255,b/255) end

local Styles = {
	Font = Enum.Font.Arial;
	Margin = 5;
	Black = CreateColor3(0,0,0);
	White = CreateColor3(255,255,255);
}

local Row = {
	Font = Styles.Font;
	FontSize = Enum.FontSize.Size14;
	TextXAlignment = Enum.TextXAlignment.Left;
	TextColor = Styles.Black;
	TextColorOver = Styles.White;
	TextLockedColor = CreateColor3(120,120,120);
	Height = 24;
	BorderColor = CreateColor3(216,216,216);
	BackgroundColor = Styles.White;
	BackgroundColorAlternate = CreateColor3(246,246,246);
	BackgroundColorMouseover = CreateColor3(211,224,244);
	TitleMarginLeft = 15;
}

local DropDown = {
	Font = Styles.Font;
	FontSize = Enum.FontSize.Size14;
	TextColor = CreateColor3(0,0,0);
	TextColorOver = Styles.White;
	TextXAlignment = Enum.TextXAlignment.Left;
	Height = 16;
	BackColor = Styles.White;
	BackColorOver = CreateColor3(86,125,188);
	BorderColor = CreateColor3(216,216,216);
	BorderSizePixel = 2;
	ArrowColor = CreateColor3(160,160,160);
	ArrowColorOver = Styles.Black;
}

local BrickColors = {
	BoxSize = 13;
	BorderSizePixel = 1;
	BorderColor = CreateColor3(160,160,160);
	FrameColor = CreateColor3(160,160,160);
	Size = 20;
	Padding = 4;
	ColorsPerRow = 8;
	OuterBorder = 1;
	OuterBorderColor = Styles.Black;
}

wait(1)

local Gui = script.Parent.Parent
local PropertiesFrame = Gui:WaitForChild("PropertiesFrame")
local ExplorerFrame = Gui:WaitForChild("ExplorerPanel")

local bindGetSelection = ExplorerFrame.GetSelection
local bindSelectionChanged = ExplorerFrame.SelectionChanged
local bindGetApi = PropertiesFrame.GetApi
local bindGetAwait = PropertiesFrame.GetAwaiting
local bindSetAwait = PropertiesFrame.SetAwaiting

local ContentUrl = ContentProvider.BaseUrl .. "asset/?id="

local SettingsRemote = Gui:WaitForChild("SettingsPanel"):WaitForChild("GetSetting")

local propertiesSearch = PropertiesFrame.Header.TextBox

local AwaitingObjectValue = false
local AwaitingObjectObj
local AwaitingObjectProp

function searchingProperties()
	if propertiesSearch.Text ~= "" and propertiesSearch.Text ~= "Search Properties" then
		return true
	end
	return false
end

local function GetSelection()
	local selection = bindGetSelection:Invoke()
	if #selection == 0 then
		return nil
	else
		return selection
	end
end


Prompt: -- Set up an on-screen thumbstick control:

Response:
local function ThumbstickSetup(frame, callback)
	local stick = frame:WaitForChild("Stick")
	local btn = frame:WaitForChild("Button")

	local btnDown = false

	-- Calculate relative position of thumbstick when dragged to screen position "pos":
	local function TouchDragged(pos)
		local x = (pos.X - frame.AbsolutePosition.X)
		local y = (pos.Y - frame.AbsolutePosition.Y)
		x = (x < 0 and 0 or x > frame.AbsoluteSize.X and frame.AbsoluteSize.X or x)
		y = (y < 0 and 0 or y > frame.AbsoluteSize.Y and frame.AbsoluteSize.Y or y)
		local ratioX = ((x / frame.AbsoluteSize.X) - 0.5) * 2
		local ratioY = -((y / frame.AbsoluteSize.Y) - 0.5) * 2
		stick.Position = UDim2.new(0, x, 0, y)
		callback(ratioX, ratioY)
	end

	local function StartTouch(pos)
		btnDown = true
		TouchDragged(pos)
		btn.Size = UDim2.new(10, 0, 10, 0)
	end

	local function StopTouch(pos)
		btnDown = false
		stick:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quint", 0.15, true)
		btn.Size = UDim2.new(1, 0, 1, 0)
		callback(0, 0)
	end

	btn.InputChanged:Connect(function(input)
		if (btnDown and input.UserInputType == Enum.UserInputType.Touch) then
			TouchDragged(input.Position)
		end
	end)

	btn.MouseButton1Down:Connect(function(x, y)
		StartTouch(Vector3.new(x, y, 0))
	end)

	btn.InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.Touch then
			StopTouch(input.Position)
		end
	end)
end -- ThumbstickSetup()


Prompt: --[[ The Class ]]

Response:
--
local BaseCharacterController = require(script.Parent:WaitForChild("BaseCharacterController"))
local VRNavigation = setmetatable({}, BaseCharacterController)
VRNavigation.__index = VRNavigation

function VRNavigation.new(CONTROL_ACTION_PRIORITY)
	local self = setmetatable(BaseCharacterController.new(), VRNavigation)

	self.CONTROL_ACTION_PRIORITY = CONTROL_ACTION_PRIORITY

	self.navigationRequestedConn = nil
	self.heartbeatConn = nil

	self.currentDestination = nil
	self.currentPath = nil
	self.currentPoints = nil
	self.currentPointIdx = 0

	self.expectedTimeToNextPoint = 0
	self.timeReachedLastPoint = tick()
	self.moving = false

	self.isJumpBound = false
	self.moveLatch = false

	self.userCFrameEnabledConn = nil

	return self
end

function VRNavigation:SetLaserPointerMode(mode)
	pcall(function()
		StarterGui:SetCore("VRLaserPointerMode", mode)
	end)
end

function VRNavigation:GetLocalHumanoid()
	local character = LocalPlayer.Character
	if not character then
		return
	end

	for _, child in pairs(character:GetChildren()) do
		if child:IsA("Humanoid") then
			return child
		end
	end
	return nil
end

function VRNavigation:HasBothHandControllers()
	return VRService:GetUserCFrameEnabled(Enum.UserCFrame.RightHand) and VRService:GetUserCFrameEnabled(Enum.UserCFrame.LeftHand)
end

function VRNavigation:HasAnyHandControllers()
	return VRService:GetUserCFrameEnabled(Enum.UserCFrame.RightHand) or VRService:GetUserCFrameEnabled(Enum.UserCFrame.LeftHand)
end

function VRNavigation:IsMobileVR()
	return UserInputService.TouchEnabled
end

function VRNavigation:HasGamepad()
	return UserInputService.GamepadEnabled
end

function VRNavigation:ShouldUseNavigationLaser()
	--Places where we use the navigation laser:
	-- mobile VR with any number of hands tracked
	-- desktop VR with only one hand tracked
	-- desktop VR with no hands and no gamepad (i.e. with Oculus remote?)
	--using an Xbox controller with a desktop VR headset means no laser since the user has a thumbstick.
	--in the future, we should query thumbstick presence with a features API
	if self:IsMobileVR() then
		return true
	else
		if self:HasBothHandControllers() then
			return false
		end
		if not self:HasAnyHandControllers() then
			return not self:HasGamepad()
		end
		return true
	end
end

function VRNavigation:StartFollowingPath(newPath)
	currentPath = newPath
	currentPoints = currentPath:GetPointCoordinates()
	currentPointIdx = 1
	moving = true

	timeReachedLastPoint = tick()

	local humanoid = self:GetLocalHumanoid()
	if humanoid and humanoid.Torso and #currentPoints >= 1 then
		local dist = (currentPoints[1] - humanoid.Torso.Position).magnitude
		expectedTimeToNextPoint = dist / humanoid.WalkSpeed
	end

	movementUpdateEvent:Fire("targetPoint", self.currentDestination)
end

function VRNavigation:GoToPoint(point)
	currentPath = true
	currentPoints = { point }
	currentPointIdx = 1
	moving = true

	local humanoid = self:GetLocalHumanoid()
	local distance = (humanoid.Torso.Position - point).magnitude
	local estimatedTimeRemaining = distance / humanoid.WalkSpeed

	timeReachedLastPoint = tick()
	expectedTimeToNextPoint = estimatedTimeRemaining

	movementUpdateEvent:Fire("targetPoint", point)
end

function VRNavigation:StopFollowingPath()
	currentPath = nil
	currentPoints = nil
	currentPointIdx = 0
	moving = false
	self.moveVector = ZERO_VECTOR3
end

function VRNavigation:TryComputePath(startPos, destination)
	local numAttempts = 0
	local newPath = nil

	while not newPath and numAttempts < 5 do
		newPath = PathfindingService:ComputeSmoothPathAsync(startPos, destination, MAX_PATHING_DISTANCE)
		numAttempts = numAttempts + 1

		if newPath.Status == Enum.PathStatus.ClosestNoPath or newPath.Status == Enum.PathStatus.ClosestOutOfRange then
			newPath = nil
			break
		end

		if newPath and newPath.Status == Enum.PathStatus.FailStartNotEmpty then
			startPos = startPos + (destination - startPos).unit
			newPath = nil
		end

		if newPath and newPath.Status == Enum.PathStatus.FailFinishNotEmpty then
			destination = destination + Vector3.new(0, 1, 0)
			newPath = nil
		end
	end

	return newPath
end

function VRNavigation:OnNavigationRequest(destinationCFrame, inputUserCFrame )
	local destinationPosition = destinationCFrame.p
	local lastDestination = self.currentDestination

	if not IsFiniteVector3(destinationPosition) then
		return
	end

	self.currentDestination = destinationPosition

	local humanoid = self:GetLocalHumanoid()
	if not humanoid or not humanoid.Torso then
		return
	end

	local currentPosition = humanoid.Torso.Position
	local distanceToDestination = (self.currentDestination - currentPosition).magnitude

	if distanceToDestination < NO_PATH_THRESHOLD then
		self:GoToPoint(self.currentDestination)
		return
	end

	if not lastDestination or (self.currentDestination - lastDestination).magnitude > RECALCULATE_PATH_THRESHOLD then
		local newPath = self:TryComputePath(currentPosition, self.currentDestination)
		if newPath then
			self:StartFollowingPath(newPath)
			if PathDisplay then
				PathDisplay.setCurrentPoints(self.currentPoints)
				PathDisplay.renderPath()
			end
		else
			self:StopFollowingPath()
			if PathDisplay then
				PathDisplay.clearRenderedPath()
			end
		end
	else
		if moving then
			self.currentPoints[#currentPoints] = self.currentDestination
		else
			self:GoToPoint(self.currentDestination)
		end
	end
end

function VRNavigation:OnJumpAction(actionName, inputState, inputObj)
	if inputState == Enum.UserInputState.Begin then
		self.isJumping = true
	end
	if FFlagPlayerScriptsBindAtPriority then
		return Enum.ContextActionResult.Sink
	end
end
function VRNavigation:BindJumpAction(active)
	if active then
		if not self.isJumpBound then
			self.isJumpBound = true
			if FFlagPlayerScriptsBindAtPriority then
				ContextActionService:BindActionAtPriority("VRJumpAction", (function() return self:OnJumpAction() end), false,
				 self.CONTROL_ACTION_PRIORITY, Enum.KeyCode.ButtonA)
			else
				ContextActionService:BindAction("VRJumpAction", (function() self:OnJumpAction() end), false, Enum.KeyCode.ButtonA)
			end
		end
	else
		if self.isJumpBound then
			self.isJumpBound = false
			ContextActionService:UnbindAction("VRJumpAction")
		end
	end
end

function VRNavigation:ControlCharacterGamepad(actionName, inputState, inputObject)
	if inputObject.KeyCode ~= Enum.KeyCode.Thumbstick1 then return end

	if inputState == Enum.UserInputState.Cancel then
		self.moveVector =  ZERO_VECTOR3
		return
	end

	if inputState ~= Enum.UserInputState.End then
		self:StopFollowingPath()
		if PathDisplay then
			PathDisplay.clearRenderedPath()
		end

		if self:ShouldUseNavigationLaser() then
			self:BindJumpAction(true)
			self:SetLaserPointerMode("Hidden")
		end

		if inputObject.Position.magnitude > THUMBSTICK_DEADZONE then
			self.moveVector = Vector3.new(inputObject.Position.X, 0, -inputObject.Position.Y)
			if self.moveVector.magnitude > 0 then
				self.moveVector = self.moveVector.unit * math.min(1, inputObject.Position.magnitude)
			end

			self.moveLatch = true
		end
	else
		self.moveVector =  ZERO_VECTOR3

		if self:ShouldUseNavigationLaser() then
			self:BindJumpAction(false)
			self:SetLaserPointerMode("Navigation")
		end

		if self.moveLatch then
			self.moveLatch = false
			movementUpdateEvent:Fire("offtrack")
		end
	end
	if FFlagPlayerScriptsBindAtPriority then
		return Enum.ContextActionResult.Sink
	end
end

function VRNavigation:OnHeartbeat(dt)
	local newMoveVector = self.moveVector
	local humanoid = self:GetLocalHumanoid()
	if not humanoid or not humanoid.Torso then
		return
	end

	if self.moving and self.currentPoints then
		local currentPosition = humanoid.Torso.Position
		local goalPosition = currentPoints[1]
		local vectorToGoal = (goalPosition - currentPosition) * XZ_VECTOR3
		local moveDist = vectorToGoal.magnitude
		local moveDir = vectorToGoal / moveDist

		if moveDist < POINT_REACHED_THRESHOLD then
			local estimatedTimeRemaining = 0
			local prevPoint = currentPoints[1]
			for i, point in pairs(currentPoints) do
				if i ~= 1 then
					local dist = (point - prevPoint).magnitude
					prevPoint = point
					estimatedTimeRemaining = estimatedTimeRemaining + (dist / humanoid.WalkSpeed)
				end
			end

			table.remove(currentPoints, 1)
			currentPointIdx = currentPointIdx + 1

			if #currentPoints == 0 then
				self:StopFollowingPath()
				if PathDisplay then
					PathDisplay.clearRenderedPath()
				end
				return
			else
				if PathDisplay then
					PathDisplay.setCurrentPoints(currentPoints)
					PathDisplay.renderPath()
				end

				local newGoal = currentPoints[1]
				local distanceToGoal = (newGoal - currentPosition).magnitude
				expectedTimeToNextPoint = distanceToGoal / humanoid.WalkSpeed
				timeReachedLastPoint = tick()
			end
		else
			local ignoreTable = {
				game.Players.LocalPlayer.Character,
				workspace.CurrentCamera
			}
			local obstructRay = Ray.new(currentPosition - Vector3.new(0, 1, 0), moveDir * 3)
			local obstructPart, obstructPoint, obstructNormal = workspace:FindPartOnRayWithIgnoreList(obstructRay, ignoreTable)

			if obstructPart then
				local heightOffset = Vector3.new(0, 100, 0)
				local jumpCheckRay = Ray.new(obstructPoint + moveDir * 0.5 + heightOffset, -heightOffset)
				local jumpCheckPart, jumpCheckPoint, jumpCheckNormal = workspace:FindPartOnRayWithIgnoreList(jumpCheckRay, ignoreTable)

				local heightDifference = jumpCheckPoint.Y - currentPosition.Y
				if heightDifference < 6 and heightDifference > -2 then
					humanoid.Jump = true
				end
			end

			local timeSinceLastPoint = tick() - timeReachedLastPoint
			if timeSinceLastPoint > expectedTimeToNextPoint + OFFTRACK_TIME_THRESHOLD then
				self:StopFollowingPath()
				if PathDisplay then
					PathDisplay.clearRenderedPath()
				end

				movementUpdateEvent:Fire("offtrack")
			end

			newMoveVector = self.moveVector:Lerp(moveDir, dt * 10)
		end
	end

	if IsFiniteVector3(newMoveVector) then
		self.moveVector = newMoveVector
	end
end

function VRNavigation:OnUserCFrameEnabled()
	if self:ShouldUseNavigationLaser() then
		self:BindJumpAction(false)
		self:SetLaserPointerMode("Navigation")
	else
		self:BindJumpAction(true)
		self:SetLaserPointerMode("Hidden")
	end
end

function VRNavigation:Enable(enable)

	self.moveVector = ZERO_VECTOR3
	self.isJumping = false

	if enable then
		self.navigationRequestedConn = VRService.NavigationRequested:Connect(function(destinationCFrame, inputUserCFrame) self:OnNavigationRequest(destinationCFrame, inputUserCFrame) end)
		self.heartbeatConn = RunService.Heartbeat:Connect(function(dt) self:OnHeartbeat(dt) end)

		if FFlagPlayerScriptsBindAtPriority then
			ContextActionService:BindAction("MoveThumbstick", (function(actionName, inputState, inputObject) return self:ControlCharacterGamepad(actionName, inputState, inputObject) end),
				false, self.CONTROL_ACTION_PRIORITY, Enum.KeyCode.Thumbstick1)
		else
			ContextActionService:BindAction("MoveThumbstick", (function(actionName, inputState, inputObject) self:ControlCharacterGamepad(actionName, inputState, inputObject) end), false, Enum.KeyCode.Thumbstick1)
		end
		ContextActionService:BindActivate(Enum.UserInputType.Gamepad1, Enum.KeyCode.ButtonR2)

		self.userCFrameEnabledConn = VRService.UserCFrameEnabled:Connect(function() self:OnUserCFrameEnabled() end)
		self:OnUserCFrameEnabled()

		VRService:SetTouchpadMode(Enum.VRTouchpad.Left, Enum.VRTouchpadMode.VirtualThumbstick)
		VRService:SetTouchpadMode(Enum.VRTouchpad.Right, Enum.VRTouchpadMode.ABXY)

		self.enabled = true
	else
		-- Disable
		self:StopFollowingPath()

		ContextActionService:UnbindAction("MoveThumbstick")
		ContextActionService:UnbindActivate(Enum.UserInputType.Gamepad1, Enum.KeyCode.ButtonR2)

		self:BindJumpAction(false)
		self:SetLaserPointerMode("Disabled")

		if self.navigationRequestedConn then
			self.navigationRequestedConn:Disconnect()
			self.navigationRequestedConn = nil
		end
		if self.heartbeatConn then
			self.heartbeatConn:Disconnect()
			self.heartbeatConn = nil
		end
		if self.userCFrameEnabledConn then
			self.userCFrameEnabledConn:Disconnect()
			self.userCFrameEnabledConn = nil
		end
		self.enabled = false
	end
end

return VRNavigation


Prompt: -- CONNECTIONS

Response:
local iconCreationCount = 0
IconController.iconAdded:Connect(function(icon)
	topbarIcons[icon] = true
	if IconController.gameTheme then
		icon:setTheme(IconController.gameTheme)
	end
	icon.updated:Connect(function()
		IconController.updateTopbar()
	end)
	-- When this icon is selected, deselect other icons if necessary
	icon.selected:Connect(function()
		local allIcons = IconController.getIcons()
		for _, otherIcon in pairs(allIcons) do
			if icon.deselectWhenOtherIconSelected and otherIcon ~= icon and otherIcon.deselectWhenOtherIconSelected and otherIcon:getToggleState() == "selected" then
				otherIcon:deselect(icon)
			end
		end
	end)
	-- Order by creation if no order specified
	iconCreationCount = iconCreationCount + 1
	icon:setOrder(iconCreationCount)
	-- Apply controller view if enabled
	if IconController.controllerModeEnabled then
		IconController._enableControllerModeForIcon(icon, true)
	end
	IconController:_updateSelectionGroup()
	IconController.updateTopbar()
end)

IconController.iconRemoved:Connect(function(icon)
	topbarIcons[icon] = nil
	icon:setEnabled(false)
	icon:deselect()
	icon.updated:Fire()
	IconController:_updateSelectionGroup()
end)


Prompt: -- Get references to the DockShelf and the AppManager frame

Response:
local gui = script.Parent.Parent.Parent.Parent.AppManager.Settings
local openGui = gui.Main
local TweenService = game:GetService("TweenService")


Prompt:
--[[

	This module script contains all the main animations. I put it into this script so it'll be easier to edit.

	Both arms are welded to a single brick called "animBase". This makes it easier to edit movement animations because you only have to
	edit the cframe of one brick instead of 2 arms.

	The idling, walking, and running animations have a Pos and a Rot component. The Pos component is the position of the weld and the Rot component
	is the rotation of the weld. They're vector3 values so the script can multiply each value by an alpha and add them together to make the smooth
	transitions possible

	The table directly below lets you know how each component of the Vector affects the movement of the weld so it's easier to edit

	This module also contains the reload animation which I moved here for easier editing. The animation function has a parameter S that contains all
	the functions and variables that are necessary to make the animation run

	HOW TO EDIT THE RELOAD ANIMATION:
		-Make sure each block of the animation is made into a separate function, it needs to be like this so if the reload animation needs to be stopped
		midway, the arms don't glitch out
		-Each animation piece should only have one wait command at the end of the function
		-Multiply every duration value, including the wait time values by the animSpeed. That way if you change the reload time, you won't have to change
		each individual time value for all the animation components

--]]

Response:
local Animations = {

	Reload = function(S) --This is the main reload animation. The parameter S contains all the variables and functions that are necessary for this animation
		--[[
			FUNCTION LIST_

				S.tweenJoint(Joint, newC0, newC1, Alpha, Duration) --This function tweens a joint to a given C0 and C1. The Alpha parameter is function
					that returns a number between 0 and 1 given an argument of a number between 0 and 90. The Duration is how fast the joint tweens. NOTE,
					you can put nil as an argument for the newC0 or newC1 parameter and the function won't tween that specific property of the weld. This
					is useful if you only want to mess with the C0 or C1 property of a weld.

				S.makeMagInvisible() --This function makes the mag invisible so it looks like the mag was removed

				S.makeMagVisible() --This function makes the mag visible again at whatever the previous transparency of the mag parts were

				S.isMagVisible() --This function returns a true or false value based on whether or not the mag is visible. This can be used to tell if
					the animation was stopped midway and where to restart the animation

				S.isMagEmpty() --This function returns a true or false value based on whether or not the mag is empty, meaning the ammo is 0. This can be
					used to decide if a chambering animation should play after the reload animation

				S.setNewMag() --This function sets the newMag variable in the clientMain to true which basically lets the script know that a new mag was
					put into the gun. This is used so that if the reload animation is broken after the new mag was put in but before the chambering animation
					then the script will simply play the chambering animation instead of putting in another mag

				S.isNewMag() --This function returns a true or false value based on whether or not the mag that is currently attached to the gun is a new
					mag. In order for it to be a new mag, it needs to have full ammo. Once you fire, the mag becomes an old mag

				S.createMag(Key) --This functions clones the Mag and puts it in a table with a Key parameter so you can access the mag in a separate
					function and it returns a Model containing the Mag and a table that contains the original mag bricks and the corresponding clone. NOTE,
					the mag bricks will be made non can collide

				S.getMag(Key) --This function gets a Mag from the mag table given a Key argument and it returns the model that the mag is contained in
					and the brick that all the other mag parts are welded to

				S.attachGripToHead() --This function detaches the grip from the right arm and attaches it to the Head. This is so you can make reload
					animations that require using the right arm to manipulate the gun in any way. The C0 of the grip is changed so the gun stays in the
					position that it was in before you detached the grip from the right arm.

				S.attachGripToArm() --This function detaches the grip from the Head and attaches it to the Arm. The C0 of the grip is changed so the gun
					stays in the position that it was in before you detached the grip from the head

				S.Sine(X) --This function is an Alpha function for the tweenJoint function. Given a number between 0 and 90, the function will return the
					sine of that number, which is a number between 0 and 1, which is used to tween a Joint with a Sine movement

				S.Linear(X) --This function is an Alpha function for the tweenJoint function. Given a number between 0 and 90, the function will return
					the number / 90, which is a number between 0 and 1, which is used to a tween a Joint with a Linear movement

			VARIABLE LIST_

				S.Handle --This variable is the Handle of gun

				S.LArm --This variable is the left arm

				S.RArm --This variable is the right arm

				S.LWeld --This variable is the left arm weld which is attached to the animBase

				S.RWeld --This variable is the right arm weld which is attached to the animBase

				S.LC0 --This variable is the cframe of the left arm joint with respect to the torso

				S.RC0 --This variable is the cframe of the right arm joint with respect to the torso

				S.Grip --This variable is the Grip weld which is attached to right arm

				S.gunIgnore --This variable is the gun ignore model which contains the fake arms and bullets and other stuff

				S.Cam --This variable is the player camera

				S.CF --This variable is the shortened form of CFrame.new which you can use instead of CFrame.new

				S.CFANG --This variable is the shortened form of CFrame.Angles which you can use instead of CFrame.Angles

				S.V3 --This variable is the shortened form of Vector3.new which you can use instead of Vector3.new

				S.RAD --This variable is the shortened form of math.rad which you can use instead of math.rad

				S.reloadTimeLoaded --This variable is the reload time for when the gun is loaded which you can use to modify how fast the reload
					animation runs

				S.reloadTimeEmpty --This variable is the reload time for when the gun is empty which you can use to modify how fast the reload
					animation runs
		--]]

		local W1 = nil
		local W2 = nil
		local animSpeed = S.isMagEmpty() and S.reloadTimeEmpty / 1.3 or S.reloadTimeLoaded / 0.9
		return {
			function()
				if (not S.isNewMag()) then
					if S.isMagVisible() then
						local Mag1, magTable1 = S.createMag("Mag1")

						Mag1.Parent = S.gunIgnore

						W1 = Instance.new("Weld")
						W1.Part0 = magTable1[1].magClone
						W1.Part1 = S.Handle
						W1.C0 = magTable1[1].Original.CFrame:toObjectSpace(S.Handle.CFrame)
						W1.Parent = magTable1[1].magClone

						S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(90), 0, S.RAD(-60)), S.Sine, 0.2 * animSpeed)
						S.tweenJoint(S.RWeld, nil, S.CF(0.3, 0.2, -0.51) * S.CFANG(S.RAD(-12), 0, S.RAD(25)), S.Sine, 0.2 * animSpeed)
						S.tweenJoint(S.Grip, nil, S.CFANG(0, S.RAD(20), S.RAD(10)), S.Sine, 0.1 * animSpeed)
						wait(0.2 * animSpeed)
					end
				end
			end;

			function()
				if (not S.isNewMag()) then
					if S.isMagVisible() then
						S.makeMagInvisible()
						W1:Destroy()
						local Mag1, magTable1 = S.getMag("Mag1")
						magTable1[1].magClone.Velocity = S.Handle.Velocity + S.Handle.CFrame:vectorToWorldSpace(S.V3(0, -1, 0)) * 20

						S.tweenJoint(S.Grip, nil, S.CFANG(0, S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					else

						S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					end

					S.tweenJoint(S.LWeld, nil, S.CF(0, 0.5, 0) * S.CFANG(S.RAD(95), 0, S.RAD(-25)), S.Sine, 0.2 * animSpeed)

					wait(0.25 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					local Mag1, magTable1 = S.getMag("Mag1")
					if Mag1 then Mag1:Destroy() end

					local Mag2, magTable2 = S.createMag("Mag2")

					Mag2.Parent = S.gunIgnore

					local LArmCF = S.LWeld.Part0.CFrame * S.LWeld.C0 * (S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60))):inverse()
					local RArmCF = S.RWeld.Part0.CFrame * S.RWeld.C0 * (S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25))):inverse()
					local handleOffsetCF = S.RArm.CFrame:toObjectSpace(S.RArm.CFrame * S.Grip.C0 * (S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10))):inverse())
					local originalMagOffsetCF = S.Handle.CFrame:toObjectSpace(magTable2[1].Original.CFrame)
					local newMagC0 = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF)

					W2 = Instance.new("Weld")
					W2.Part0 = S.LArm
					W2.Part1 = magTable2[1].magClone
					W2.C0 = newMagC0
					W2.Parent = magTable2[1].magClone

					S.tweenJoint(S.LWeld, nil, S.CF(0.55, 0.6, -2.4) * S.CFANG(S.RAD(-20), S.RAD(20), S.RAD(-60)), S.Sine, 0.2 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-12), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					wait(0.2 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.15 * animSpeed)
					S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60)), S.Sine, 0.15 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					script.Parent.Handle.MagIn:Play()
					wait(0.2 * animSpeed)
				end
			end;
						function()
				if (not S.isNewMag()) then
					if S.isMagVisible() then
						S.makeMagInvisible()
						W1:Destroy()
						local Mag1, magTable1 = S.getMag("Mag1")
						magTable1[1].magClone.Velocity = S.Handle.Velocity + S.Handle.CFrame:vectorToWorldSpace(S.V3(0, -1, 0)) * 20

						S.tweenJoint(S.Grip, nil, S.CFANG(0, S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					else

						S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					end

					S.tweenJoint(S.LWeld, nil, S.CF(0, 0.5, 0) * S.CFANG(S.RAD(95), 0, S.RAD(-25)), S.Sine, 0.2 * animSpeed)

					wait(0.25 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					local Mag1, magTable1 = S.getMag("Mag1")
					if Mag1 then Mag1:Destroy() end

					local Mag2, magTable2 = S.createMag("Mag2")

					Mag2.Parent = S.gunIgnore

					local LArmCF = S.LWeld.Part0.CFrame * S.LWeld.C0 * (S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60))):inverse()
					local RArmCF = S.RWeld.Part0.CFrame * S.RWeld.C0 * (S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25))):inverse()
					local handleOffsetCF = S.RArm.CFrame:toObjectSpace(S.RArm.CFrame * S.Grip.C0 * (S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10))):inverse())
					local originalMagOffsetCF = S.Handle.CFrame:toObjectSpace(magTable2[1].Original.CFrame)
					local newMagC0 = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF)

					W2 = Instance.new("Weld")
					W2.Part0 = S.LArm
					W2.Part1 = magTable2[1].magClone
					W2.C0 = newMagC0
					W2.Parent = magTable2[1].magClone

					S.tweenJoint(S.LWeld, nil, S.CF(0.55, 0.6, -2.4) * S.CFANG(S.RAD(-20), S.RAD(20), S.RAD(-60)), S.Sine, 0.2 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-12), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					wait(0.2 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.15 * animSpeed)
					S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60)), S.Sine, 0.15 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					script.Parent.Handle.MagIn:Play()
					wait(0.2 * animSpeed)
				end
			end;
						function()
				if (not S.isNewMag()) then
					if S.isMagVisible() then
						S.makeMagInvisible()
						W1:Destroy()
						local Mag1, magTable1 = S.getMag("Mag1")
						magTable1[1].magClone.Velocity = S.Handle.Velocity + S.Handle.CFrame:vectorToWorldSpace(S.V3(0, -1, 0)) * 20

						S.tweenJoint(S.Grip, nil, S.CFANG(0, S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					else

						S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					end

					S.tweenJoint(S.LWeld, nil, S.CF(0, 0.5, 0) * S.CFANG(S.RAD(95), 0, S.RAD(-25)), S.Sine, 0.2 * animSpeed)

					wait(0.25 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					local Mag1, magTable1 = S.getMag("Mag1")
					if Mag1 then Mag1:Destroy() end

					local Mag2, magTable2 = S.createMag("Mag2")

					Mag2.Parent = S.gunIgnore

					local LArmCF = S.LWeld.Part0.CFrame * S.LWeld.C0 * (S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60))):inverse()
					local RArmCF = S.RWeld.Part0.CFrame * S.RWeld.C0 * (S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25))):inverse()
					local handleOffsetCF = S.RArm.CFrame:toObjectSpace(S.RArm.CFrame * S.Grip.C0 * (S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10))):inverse())
					local originalMagOffsetCF = S.Handle.CFrame:toObjectSpace(magTable2[1].Original.CFrame)
					local newMagC0 = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF)

					W2 = Instance.new("Weld")
					W2.Part0 = S.LArm
					W2.Part1 = magTable2[1].magClone
					W2.C0 = newMagC0
					W2.Parent = magTable2[1].magClone

					S.tweenJoint(S.LWeld, nil, S.CF(0.55, 0.6, -2.4) * S.CFANG(S.RAD(-20), S.RAD(20), S.RAD(-60)), S.Sine, 0.2 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-12), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					wait(0.2 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.15 * animSpeed)
					S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60)), S.Sine, 0.15 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					script.Parent.Handle.MagIn:Play()
					wait(0.2 * animSpeed)
				end
			end;
						function()
				if (not S.isNewMag()) then
					if S.isMagVisible() then
						S.makeMagInvisible()
						W1:Destroy()
						local Mag1, magTable1 = S.getMag("Mag1")
						magTable1[1].magClone.Velocity = S.Handle.Velocity + S.Handle.CFrame:vectorToWorldSpace(S.V3(0, -1, 0)) * 20

						S.tweenJoint(S.Grip, nil, S.CFANG(0, S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					else

						S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					end

					S.tweenJoint(S.LWeld, nil, S.CF(0, 0.5, 0) * S.CFANG(S.RAD(95), 0, S.RAD(-25)), S.Sine, 0.2 * animSpeed)

					wait(0.25 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					local Mag1, magTable1 = S.getMag("Mag1")
					if Mag1 then Mag1:Destroy() end

					local Mag2, magTable2 = S.createMag("Mag2")

					Mag2.Parent = S.gunIgnore

					local LArmCF = S.LWeld.Part0.CFrame * S.LWeld.C0 * (S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60))):inverse()
					local RArmCF = S.RWeld.Part0.CFrame * S.RWeld.C0 * (S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25))):inverse()
					local handleOffsetCF = S.RArm.CFrame:toObjectSpace(S.RArm.CFrame * S.Grip.C0 * (S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10))):inverse())
					local originalMagOffsetCF = S.Handle.CFrame:toObjectSpace(magTable2[1].Original.CFrame)
					local newMagC0 = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF)

					W2 = Instance.new("Weld")
					W2.Part0 = S.LArm
					W2.Part1 = magTable2[1].magClone
					W2.C0 = newMagC0
					W2.Parent = magTable2[1].magClone

					S.tweenJoint(S.LWeld, nil, S.CF(0.55, 0.6, -2.4) * S.CFANG(S.RAD(-20), S.RAD(20), S.RAD(-60)), S.Sine, 0.2 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-12), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					wait(0.2 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.15 * animSpeed)
					S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60)), S.Sine, 0.15 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					script.Parent.Handle.MagIn:Play()
					wait(0.2 * animSpeed)
				end
			end;
						function()
				if (not S.isNewMag()) then
					if S.isMagVisible() then
						S.makeMagInvisible()
						W1:Destroy()
						local Mag1, magTable1 = S.getMag("Mag1")
						magTable1[1].magClone.Velocity = S.Handle.Velocity + S.Handle.CFrame:vectorToWorldSpace(S.V3(0, -1, 0)) * 20

						S.tweenJoint(S.Grip, nil, S.CFANG(0, S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					else

						S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					end

					S.tweenJoint(S.LWeld, nil, S.CF(0, 0.5, 0) * S.CFANG(S.RAD(95), 0, S.RAD(-25)), S.Sine, 0.2 * animSpeed)

					wait(0.25 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					local Mag1, magTable1 = S.getMag("Mag1")
					if Mag1 then Mag1:Destroy() end

					local Mag2, magTable2 = S.createMag("Mag2")

					Mag2.Parent = S.gunIgnore

					local LArmCF = S.LWeld.Part0.CFrame * S.LWeld.C0 * (S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60))):inverse()
					local RArmCF = S.RWeld.Part0.CFrame * S.RWeld.C0 * (S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25))):inverse()
					local handleOffsetCF = S.RArm.CFrame:toObjectSpace(S.RArm.CFrame * S.Grip.C0 * (S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10))):inverse())
					local originalMagOffsetCF = S.Handle.CFrame:toObjectSpace(magTable2[1].Original.CFrame)
					local newMagC0 = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF)

					W2 = Instance.new("Weld")
					W2.Part0 = S.LArm
					W2.Part1 = magTable2[1].magClone
					W2.C0 = newMagC0
					W2.Parent = magTable2[1].magClone

					S.tweenJoint(S.LWeld, nil, S.CF(0.55, 0.6, -2.4) * S.CFANG(S.RAD(-20), S.RAD(20), S.RAD(-60)), S.Sine, 0.2 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-12), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					wait(0.2 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.15 * animSpeed)
					S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60)), S.Sine, 0.15 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					script.Parent.Handle.MagIn:Play()
					wait(0.2 * animSpeed)
				end
			end;
						function()
				if (not S.isNewMag()) then
					if S.isMagVisible() then
						S.makeMagInvisible()
						W1:Destroy()
						local Mag1, magTable1 = S.getMag("Mag1")
						magTable1[1].magClone.Velocity = S.Handle.Velocity + S.Handle.CFrame:vectorToWorldSpace(S.V3(0, -1, 0)) * 20

						S.tweenJoint(S.Grip, nil, S.CFANG(0, S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					else

						S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					end

					S.tweenJoint(S.LWeld, nil, S.CF(0, 0.5, 0) * S.CFANG(S.RAD(95), 0, S.RAD(-25)), S.Sine, 0.2 * animSpeed)

					wait(0.25 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					local Mag1, magTable1 = S.getMag("Mag1")
					if Mag1 then Mag1:Destroy() end

					local Mag2, magTable2 = S.createMag("Mag2")

					Mag2.Parent = S.gunIgnore

					local LArmCF = S.LWeld.Part0.CFrame * S.LWeld.C0 * (S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60))):inverse()
					local RArmCF = S.RWeld.Part0.CFrame * S.RWeld.C0 * (S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25))):inverse()
					local handleOffsetCF = S.RArm.CFrame:toObjectSpace(S.RArm.CFrame * S.Grip.C0 * (S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10))):inverse())
					local originalMagOffsetCF = S.Handle.CFrame:toObjectSpace(magTable2[1].Original.CFrame)
					local newMagC0 = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF)

					W2 = Instance.new("Weld")
					W2.Part0 = S.LArm
					W2.Part1 = magTable2[1].magClone
					W2.C0 = newMagC0
					W2.Parent = magTable2[1].magClone

					S.tweenJoint(S.LWeld, nil, S.CF(0.55, 0.6, -2.4) * S.CFANG(S.RAD(-20), S.RAD(20), S.RAD(-60)), S.Sine, 0.2 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-12), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					wait(0.2 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.15 * animSpeed)
					S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60)), S.Sine, 0.15 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					script.Parent.Handle.MagIn:Play()
					wait(0.2 * animSpeed)
				end
			end;
						function()
				if (not S.isNewMag()) then
					if S.isMagVisible() then
						S.makeMagInvisible()
						W1:Destroy()
						local Mag1, magTable1 = S.getMag("Mag1")
						magTable1[1].magClone.Velocity = S.Handle.Velocity + S.Handle.CFrame:vectorToWorldSpace(S.V3(0, -1, 0)) * 20

						S.tweenJoint(S.Grip, nil, S.CFANG(0, S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					else

						S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					end

					S.tweenJoint(S.LWeld, nil, S.CF(0, 0.5, 0) * S.CFANG(S.RAD(95), 0, S.RAD(-25)), S.Sine, 0.2 * animSpeed)

					wait(0.25 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					local Mag1, magTable1 = S.getMag("Mag1")
					if Mag1 then Mag1:Destroy() end

					local Mag2, magTable2 = S.createMag("Mag2")

					Mag2.Parent = S.gunIgnore

					local LArmCF = S.LWeld.Part0.CFrame * S.LWeld.C0 * (S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60))):inverse()
					local RArmCF = S.RWeld.Part0.CFrame * S.RWeld.C0 * (S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25))):inverse()
					local handleOffsetCF = S.RArm.CFrame:toObjectSpace(S.RArm.CFrame * S.Grip.C0 * (S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10))):inverse())
					local originalMagOffsetCF = S.Handle.CFrame:toObjectSpace(magTable2[1].Original.CFrame)
					local newMagC0 = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF)

					W2 = Instance.new("Weld")
					W2.Part0 = S.LArm
					W2.Part1 = magTable2[1].magClone
					W2.C0 = newMagC0
					W2.Parent = magTable2[1].magClone

					S.tweenJoint(S.LWeld, nil, S.CF(0.55, 0.6, -2.4) * S.CFANG(S.RAD(-20), S.RAD(20), S.RAD(-60)), S.Sine, 0.2 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-12), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					wait(0.2 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.15 * animSpeed)
					S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60)), S.Sine, 0.15 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					script.Parent.Handle.MagIn:Play()
					wait(0.2 * animSpeed)
				end
			end;
						function()
				if (not S.isNewMag()) then
					if S.isMagVisible() then
						S.makeMagInvisible()
						W1:Destroy()
						local Mag1, magTable1 = S.getMag("Mag1")
						magTable1[1].magClone.Velocity = S.Handle.Velocity + S.Handle.CFrame:vectorToWorldSpace(S.V3(0, -1, 0)) * 20

						S.tweenJoint(S.Grip, nil, S.CFANG(0, S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					else

						S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					end

					S.tweenJoint(S.LWeld, nil, S.CF(0, 0.5, 0) * S.CFANG(S.RAD(95), 0, S.RAD(-25)), S.Sine, 0.2 * animSpeed)

					wait(0.25 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					local Mag1, magTable1 = S.getMag("Mag1")
					if Mag1 then Mag1:Destroy() end

					local Mag2, magTable2 = S.createMag("Mag2")

					Mag2.Parent = S.gunIgnore

					local LArmCF = S.LWeld.Part0.CFrame * S.LWeld.C0 * (S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60))):inverse()
					local RArmCF = S.RWeld.Part0.CFrame * S.RWeld.C0 * (S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25))):inverse()
					local handleOffsetCF = S.RArm.CFrame:toObjectSpace(S.RArm.CFrame * S.Grip.C0 * (S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10))):inverse())
					local originalMagOffsetCF = S.Handle.CFrame:toObjectSpace(magTable2[1].Original.CFrame)
					local newMagC0 = LArmCF:toObjectSpace(RArmCF * handleOffsetCF * originalMagOffsetCF)

					W2 = Instance.new("Weld")
					W2.Part0 = S.LArm
					W2.Part1 = magTable2[1].magClone
					W2.C0 = newMagC0
					W2.Parent = magTable2[1].magClone

					S.tweenJoint(S.LWeld, nil, S.CF(0.55, 0.6, -2.4) * S.CFANG(S.RAD(-20), S.RAD(20), S.RAD(-60)), S.Sine, 0.2 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-12), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.2 * animSpeed)
					wait(0.2 * animSpeed)
				end
			end;

			function()
				if (not S.isNewMag()) then
					S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.15 * animSpeed)
					S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60)), S.Sine, 0.15 * animSpeed)--0.25
					S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					script.Parent.Handle.MagIn:Play()
					wait(0.2 * animSpeed)
				end
			end;
			function()
				if (not S.isNewMag()) then
					local Mag1, _ = S.getMag("Mag1")
					local Mag2, _ = S.getMag("Mag2")
					S.makeMagVisible()
					S.setNewMag()
					if Mag1 then Mag1:Destroy() end
					Mag2:Destroy()
				end
			end;

			function()
				if S.isMagEmpty() then
					if S.isNewMag() then
						S.tweenJoint(S.Grip, nil, S.CFANG(S.RAD(-10), S.RAD(20), S.RAD(10)), S.Sine, 0.15 * animSpeed)
						S.tweenJoint(S.LWeld, nil, S.CF(0.58, 1.63, -1.4) * S.CFANG(S.RAD(-22), S.RAD(20), S.RAD(-60)), S.Sine, 0.15 * animSpeed)--0.25
						S.tweenJoint(S.RWeld, nil, S.CF(0.6, 0.2, -0.61) * S.CFANG(S.RAD(-15), S.RAD(20), S.RAD(25)), S.Sine, 0.2 * animSpeed)
					end
					S.tweenJoint(S.LWeld, nil, S.CF(0.2, 1.9, -0.45) * S.CFANG(S.RAD(-23), 0.1, S.RAD(-40)), S.Sine, 0.1 * animSpeed)

					wait(0.4 * animSpeed)
				end
			end;

			function()
				if S.isMagEmpty() then
					S.tweenJoint(S.LWeld, nil, S.CF(-0.2, 1.7, -0.45) * S.CFANG(S.RAD(-23), 0.1, S.RAD(-40)), S.Sine, 0.1 * animSpeed)
					script.Parent.Handle.Prime:Play()
					wait(0.3 * animSpeed)
				end
			end;

			function()
				if S.isMagEmpty() then
					S.tweenJoint(S.LWeld, nil, S.CF(0.2, 1.9, -0.45) * S.CFANG(S.RAD(-23), 0.1, S.RAD(-40)), S.Sine, 0.1 * animSpeed)

					wait(0.3 * animSpeed)

				end
			end;
		}
	end;

	Cocking = function(S)

	end;

	Crawling = function(X, moveDirection, moveSpeed) --This is the animation for when you're crawling
		--[[
			The moveDirection gives you the angle at which your character is moving with respect to the way you're facing. So if you're
			moving to the right and you're facing forward then the moveDirection will give you an angle of -90. If you're moving backward
			and you're facing forward then the moveDirection will give you an angle of 180. I use this angle to adjust the crawling animation
			so that you're arms move in the direction that you're moving so it looks more realistic rather than the arms constantly moving forward

			The moveVelocity gives you how fast you're moving in the X-Z plane. It doesn't take your Y-velocity into account so if you're falling your
			moveVelocity will still be how fast you're moving horizontally. You can use this to adjust how fast the crawling animation runs so if you're
			moving really slow the animation will play slower
		--]]
		return {
			leftArm = CFrame.Angles( --This is what the cframe of the right arm will be when you're crawling
				0,
				math.rad(90),
				math.rad(-10)
			) * CFrame.new(
				math.sin(moveDirection) * (math.sin(X * 6) / 4) - 0.2,
				math.cos(moveDirection) * (math.sin(X * 6) / 2) - 0.1,
				math.max(math.cos(X * 6) / 4, 0) - 0.1
			) * CFrame.Angles(
				-math.max(math.cos(X * 6) / 4, 0),
				0,
				0
			);
			leftLeg = CFrame.new( --This is what the cframe of the left leg will be when you're crawling
				math.sin(moveDirection) * (-math.sin(X * 6) / 4) - 0.2,
				math.cos(moveDirection) * (math.sin(X * 6) / 2) + 0.3,
				math.max(math.cos(X * 6) / 4, 0) - 0.1
			):inverse() * CFrame.Angles(
				0,
				0,
				-math.rad(15) - math.cos(moveDirection) * (math.rad(15) * math.sin(X * 6))
			);
			rightArm = CFrame.Angles( --This is what the cframe of the left arm will be when you're crawling
				0,
				math.rad(-5),
				math.rad(10)
			) * CFrame.new(
				math.sin(moveDirection) * (-math.sin(X * 6) / 4) + 0.2,
				math.cos(moveDirection) * (-math.sin(X * 6) / 5) - 0.2,
				math.max(math.cos((X + math.rad(30)) * 6) / 10, 0) - 0.1
			) * CFrame.Angles(
				-math.max(math.cos((X + math.rad(30)) * 6) / 10, 0),
				0,
				0
			);
			rightLeg = CFrame.new( --This is what the cframe of the right leg will be when you're crawling
				math.sin(moveDirection) * (math.sin(X * 6) / 4) + 0.2,
				math.cos(moveDirection) * (-math.sin(X * 6) / 2) + 0.3,
				math.max(math.cos((X + math.rad(30)) * 6) / 4, 0) - 0.1
			):inverse() * CFrame.Angles(
				0,
				0,
				math.rad(15) - math.cos(moveDirection) * (math.rad(15) * math.sin(X * 6))
			);
			Grip = CFrame.Angles( --This is what the cframe of the grip will be when you're crawling
				math.max(math.cos((X + math.rad(30)) * 6) / 7, 0),
				math.rad(5),
				0
			);
			Camera = 1.5 * math.rad(math.cos((X + math.rad(30)) * 6)) + math.rad(0.5); --This is what the roll of the camera will be when you're crawling
		}
	end;

	Idling = { --This table holds the Idling animations

		unAimed = function(X) --This is the animation when the gun is not aimed
			return {
				Pos = Vector3.new(
					math.sin(X / 2) / 70, --Side to Side motion
					math.sin(X * 5 / 4) / 70, --Up and Down motion
					math.sin(X * 3 / 4) / 70 --Forward and backward motion
				);
				Rot = Vector3.new(
					0, --Pitch rotation
					0, --Yaw rotation
					0 --Roll rotation
				);
			}
		end;

		Aimed = function(X) --This is the animation when the gun is aimed
			return {
				Pos = Vector3.new(
					math.sin(X * 3 / 8) / 120,
					math.sin(X * 15 / 16) / 120,
					0
				);
				Rot = Vector3.new(
					0,
					0,
					0
				);
			}
		end;

	};

	Walking = { --This table holds the Walking animations

		unAimed = function(X) --This is the animation when the gun is not aimed
			return {
				Pos = Vector3.new(
					4 * math.sin(X * 4.5) / 50,
					1.5 * math.sin(X * 9) / 50,
					0
				);
				Rot = Vector3.new(
					0,
					0,
					math.rad(math.sin(X * 4.5)) * 2
				);
			}
		end;

		Aimed = function(X) --This is the animation when the gun is aimed
			return {
				Pos = Vector3.new(
					2 * math.sin(X * 3) / 150,
					0.75 * math.sin(X * 6) / 150,
					0
				);
				Rot = Vector3.new(
					0,
					0,
					math.rad(math.sin(X * 3)) / 3
				);
			}
		end;

	};

	Running = function(X) --This is the animation when the player is running
		return {
			Pos = Vector3.new(
				4 * math.sin(X * 4.5 * 1.5) / 30,
				1.5 * math.sin(X * 9 * 1.5) / 40 + 0.2,
				0
			);
			Rot = Vector3.new(
				0,
				-math.rad(math.sin(X * 4.5 * 1.5)) * 5 + math.rad(3),
				math.rad(math.sin(X * 4.5 * 1.5)) * 5
			);
		}
	end;

}

return Animations


Prompt: -- Casts and recasts until it hits either: nothing, or something not transparent or collidable

Response:
local function PiercingCast(fromPoint, toPoint, ignoreList) --NOTE: Modifies ignoreList!
	repeat
		local hitPart, hitPoint = CastRay(fromPoint, toPoint, ignoreList)
		if hitPart and (hitPart.Transparency > 0.95 or hitPart.CanCollide == false) then
			table.insert(ignoreList, hitPart)
		else
			return hitPart, hitPoint
		end
	until false
end

local function ScreenToWorld(screenPoint, screenSize, pushDepth)
	local cameraFOV, cameraCFrame = Camera.FieldOfView, Camera.CoordinateFrame
	local imagePlaneDepth = screenSize.y / (2 * math.tan(math.rad(cameraFOV) / 2))
	local direction = Vector3.new(screenPoint.x - (screenSize.x / 2), (screenSize.y / 2) - screenPoint.y, -imagePlaneDepth)
	local worldDirection = (cameraCFrame:vectorToWorldSpace(direction)).Unit
	local theta = math.acos(math.min(1, worldDirection:Dot(cameraCFrame.lookVector)))
	local fixedPushDepth = pushDepth / math.sin((math.pi / 2) - theta)
	return cameraCFrame.p + worldDirection * fixedPushDepth
end

local function OnCameraChanged(property)
	if property == 'CameraSubject' then
		local newSubject = Camera.CameraSubject
		if newSubject and newSubject:IsA('VehicleSeat') then
			VehicleParts = newSubject:GetConnectedParts(true)
		else
			VehicleParts = {}
		end
	end
end

local function OnCharacterAdded(player, character)
	PlayerCharacters[player] = character
end

local function OnPlayersChildAdded(child)
	if child:IsA('Player') then
		child.CharacterAdded:connect(function(character)
			OnCharacterAdded(child, character)
		end)
		if child.Character then
			OnCharacterAdded(child, child.Character)
		end
	end
end

local function OnPlayersChildRemoved(child)
	if child:IsA('Player') then
		PlayerCharacters[child] = nil
	end
end

local function OnWorkspaceChanged(property)
	if property == 'CurrentCamera' then
		local newCamera = workspace.CurrentCamera
		if newCamera then
			Camera = newCamera

			if CameraChangeConn then
				CameraChangeConn:disconnect()
			end
			CameraChangeConn = Camera.Changed:connect(OnCameraChanged)
		end
	end
end


Prompt: -- ROBLOX upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-util/src/preRunMessage.ts


Prompt: --easter egg

Response:
mouse.KeyDown:connect(function(key)
	if key=="u" and script.Blown.Value == false then
		Heat = Heat+100
	end
end)

if not FE then

radiator.Oil.Enabled = false
radiator.Antifreeze.Enabled = false
radiator.Liquid.Volume = 0
radiator.Fan:Play()
radiator.Fan.Pitch = 1+FanSpeed
radiator.Steam:Play()
radiator.Liquid:Play()
script.Blown.Value = false

while wait(.2) do
	if Heat > FanTemp and Fan == true then
		FanCool = -FanSpeed
		radiator.Fan.Volume = FanVolume
	elseif Heat < FanTempAlpha then
		FanCool = 0
		radiator.Fan.Volume = 0
	end

	Load = ((script.Parent.Parent.Values.Throttle.Value*script.Parent.Parent.Values.RPM.Value*10*OverheatSpeed)/math.ceil((car.DriveSeat.Velocity.magnitude+.0000001)/100)/75000)-CoolingEfficiency
	Heat = math.max(RunningTemp,(Heat+Load)+FanCool)

	if Heat >= BlowupTemp then
		Heat = BlowupTemp
		radiator.Break:Play()
		radiator.Liquid.Volume = .5
		radiator.Oil.Enabled = true
		radiator.Antifreeze.Enabled = true
		script.Parent.Parent.IsOn.Value = false
		script.Blown.Value = true
		car.Body.ExhaustH.Fire.Fire.Enabled = true
		car.Body.ExhaustH.Fire.FireLight.Enabled = true
		car.Body.ExhaustH.Fire.Smoke.Enabled = true
	elseif Heat >= BlowupTemp-20 then
		radiator.Smoke.Transparency = NumberSequence.new((BlowupTemp-Heat)/10,1)
		radiator.Smoke.Enabled = true
		radiator.Steam.Volume = math.abs(((BlowupTemp-Heat)-10)/10)
	else
		radiator.Smoke.Enabled = false
		radiator.Steam.Volume = 0
		car.Body.ExhaustH.Fire.Fire.Enabled = false
		car.Body.ExhaustH.Fire.FireLight.Enabled = false
		car.Body.ExhaustH.Fire.Smoke.Enabled = false
	end

	script.Celsius.Value = Heat
	script.Parent.Temp.Text = math.floor(Heat).."°c"
	script.Parent.Temp.TextColor3 = Color3.fromRGB(255,255-((Heat-FanTemp)*10),255-((Heat-FanTemp)*10))
end

else

	handler:FireServer("Initialize",FanSpeed)
while wait(.2) do

	if Heat > FanTemp and Fan == true then
		FanCool = -FanSpeed
		handler:FireServer("FanVolume",FanVolume)
	else
		FanCool = 0
		handler:FireServer("FanVolume",0)
	end

	Load = ((script.Parent.Parent.Values.Throttle.Value*script.Parent.Parent.Values.RPM.Value*10*OverheatSpeed)/math.ceil((car.DriveSeat.Velocity.magnitude+.0000001)/100)/75000)-CoolingEfficiency
	Heat = math.max(RunningTemp,(Heat+Load)+FanCool)

	if Heat >= BlowupTemp then
		Heat = BlowupTemp
		handler:FireServer("Blown")
		script.Parent.Parent.IsOn.Value = false
		script.Blown.Value = true
	elseif Heat >= BlowupTemp-10 then
		handler:FireServer("Smoke",true,BlowupTemp,Heat)
	else
		handler:FireServer("Smoke",false,BlowupTemp,Heat)
	end

	script.Celsius.Value = Heat
	script.Parent.Temp.Text = math.floor(Heat).."°c"
end
end


Prompt:
--- Add a task to clean up
-- @usage
-- Maid[key] = (function)         Adds a task to perform
-- Maid[key] = (event connection) Manages an event connection
-- Maid[key] = (Maid)             Maids can act as an event connection, allowing a Maid to have other maids to clean up.
-- Maid[key] = (Object)           Maids can cleanup objects with a `Destroy` method
-- Maid[key] = nil                Removes a named task. If the task is an event, it is disconnected. If it is an object,
--                                it is destroyed.

Response:
function Maid:__newindex(index, newTask)
	if Maid[index] ~= nil then
		error(("'%s' is reserved"):format(tostring(index)), 2)
	end

	local tasks = self._tasks
	local oldTask = tasks[index]
	tasks[index] = newTask

	if oldTask then
		if type(oldTask) == "function" then
			oldTask()
		elseif typeof(oldTask) == "RBXScriptConnection" then
			oldTask:Disconnect()
		elseif oldTask.Destroy then
			oldTask:Destroy()
		end
	end
end


Prompt: -- [[[[[[[[[[[[[[[[[  MAIN GAME LOOP  ]]]]]]]]]]]]]]]]] --

Response:
while wait() do

    -- 1. Check for at least two players
    repeat
        local availablePlayers = {} -- creating an empty table to fill

        for i, v in pairs(game.Players:GetPlayers()) do
            if not v:FindFirstChild("InMenu") then
                table.insert(availablePlayers,v)
            end
        end

        Status.Value = "Need at least two players"..#availablePlayers.."/2"

        -- need to wait or else it will crash the game
        wait (2)

    until #availablePlayers >= 2

    RoundModule.Intermission(5)

    print ("Intermission end .. Setup beginning")

    -- [[[[[[[[[[[[[[[[[  GAME START  ]]]]]]]]]]]]]]]]] --

    -- 2a. Choose a Map and import to the workspace
    local chosenChapter = RoundModule.SelectChapter() -- returns a map object of the chosen chapter
    local clonedChapter = chosenChapter:Clone() -- making a copy to not mess up the Chapters folder instance
    clonedChapter.Name = "Map" -- used in other scripts
    clonedChapter.Parent = game.Workspace -- put in view of the player so they can teleport to it

    print ("Map Chosen")

    -- 2b. Setup the doors

    -- wait a bit to load the doors
    wait (2)

    local DoorModule = require(script.DoorModule)

    if clonedChapter:FindFirstChild("Doors") then
        DoorModule.ActivateDoors(clonedChapter.Doors) -- sending in a folder
    else
        warn("Fatal Error, please have Doors folder in the Chapter Map Model -- Also the Door parts in the Doors folder")
    end

    print ("Doors Setup")

    -- 3. Choose Piggy from players NOT in the menu
    --      a player is in the menu if they did not click on 'Play' yet
    --      a player is in the menu if the player has a tag attached. the tag gets deleted/destroyed once the player clicks play
    local contestants = {} -- creating an empty table to fill

    for i, v in pairs(game.Players:GetPlayers()) do
        if not v:FindFirstChild("InMenu") then
            table.insert(contestants,v)
        end
    end

    local chosenPiggy = RoundModule.ChoosePiggy(contestants)

    -- remove chosen piggy from list of contestants
    for i, v in pairs(contestants) do
        if v == chosenPiggy then
            table.remove(contestants,i)
        else
            -- loop through all non-piggy players
            game.ReplicatedStorage.ToggleCrouch:FireClient(v, true)
        end
    end

    -- Dress up chosen contestant as Piggy!
    RoundModule.DressPiggy(chosenPiggy)

    -- avoids "torso" issue when the player is falling and the map loads afterwards
    print ("Piggy Chosen")

    -- 4. Teleport Piggy and players to their spawn spots

    RoundModule.TeleportPiggy(chosenPiggy)
    RoundModule.TeleportPlayers(contestants, clonedChapter.PlayerSpawns:GetChildren())

    print ("Players teleported to map")

    -- 5. Tag players as "contestant" and as "piggy"

    RoundModule.InsertTag(contestants, "Contestant")
    RoundModule.InsertTag({chosenPiggy}, "Piggy")

    print ("Game Start")

    -- 6. Start the game!
    RoundModule.StartRound(1200, chosenPiggy, clonedChapter)

    -- [[[[[[[[[[[[[[[[[  GAME END  ]]]]]]]]]]]]]]]]] --

    -- 7. Game ended, time to clean up!
    contestants = {}
    for i, v in pairs(game.Players:GetPlayers()) do

        -- if an existing player is not in the menu, add them to the table
        if not v:FindFirstChild("InMenu") then
            table.insert(contestants,v)
        end
    end

    -- ERROR CHECK: check if the spawns folder is in the gamespace
    if game.Workspace.Lobby:FindFirstChild("Spawns") then
        RoundModule.TeleportPlayers(contestants, game.Workspace.Lobby.Spawns:GetChildren())
    end

    -- destroy the map
    clonedChapter:Destroy()

    -- clean up piggy and players (remove tags and tools)
    RoundModule.RemoveTags()

end


Prompt:
--[[*
 * inlined Object.is polyfill to avoid requiring consumers ship their own
 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
 ]]

Response:
local function is(x: any, y: any): boolean
	return x == y and (x ~= 0 or 1 / x == 1 / y) or x ~= x and y ~= y -- eslint-disable-line no-self-compare
end


Prompt:
--[[
	Used to set a handler for when the promise resolves, rejects, or is
	cancelled. Returns a new promise chained from this promise.
]]

Response:
function Promise.prototype:finally(finallyHandler)
	self._unhandledRejection = false

	-- Return a promise chained off of this promise
	return Promise.new(function(resolve, reject)
		local finallyCallback = resolve
		if finallyHandler then
			finallyCallback = createAdvancer(finallyHandler, resolve, reject)
		end

		if self._status == Promise.Status.Started then
			-- The promise is not settled, so queue this.
			table.insert(self._queuedFinally, finallyCallback)
		else
			-- The promise already settled or was cancelled, run the callback now.
			finallyCallback(self._status)
		end
	end, self)
end


Response:
script.Parent:WaitForChild("A-Chassis Interface")
script.Parent:WaitForChild("Plugins")
script.Parent:WaitForChild("README")

local car=script.Parent.Parent
local _Tune=require(script.Parent)

local Drive=car.Wheels:GetChildren()

function getParts(model,t,a)
	for i,v in pairs(model:GetChildren()) do
		if v:IsA("BasePart") then table.insert(t,{v,a.CFrame:toObjectSpace(v.CFrame)})
		elseif v:IsA("Model") then getParts(v,t,a)
		end
	end
end

for _,v in pairs(Drive) do

	for _,a in pairs({"Top","Bottom","Left","Right","Front","Back"}) do
		v[a.."Surface"]=Enum.SurfaceType.SmoothNoOutlines
	end

	local WParts = {}

	local tPos = v.Position-car.DriveSeat.Position
	if v.Name=="FL" or v.Name=="RL" then
		v.CFrame = car.DriveSeat.CFrame*CFrame.Angles(math.rad(90),0,math.rad(90))
	else
		v.CFrame = car.DriveSeat.CFrame*CFrame.Angles(math.rad(90),0,math.rad(-90))
	end
	v.CFrame = v.CFrame+tPos

	if v:FindFirstChild("Parts")~=nil then
		getParts(v.Parts,WParts,v)
	end
	if v:FindFirstChild("Fixed")~=nil then
		getParts(v.Fixed,WParts,v)
	end

	if v.Name=="FL" or v.Name=="FR" then
		v.CFrame = v.CFrame*CFrame.Angles(math.rad(_Tune.FCamber),0,0)
		if v.Name=="FL" then
			v.CFrame = v.CFrame*CFrame.Angles(0,0,math.rad(_Tune.FToe))
		else
			v.CFrame = v.CFrame*CFrame.Angles(0,0,math.rad(-_Tune.FToe))
		end
	elseif v.Name=="RL" or v.Name=="RR" then
		v.CFrame = v.CFrame*CFrame.Angles(math.rad(_Tune.RCamber),0,0)
		if v.Name=="RL" then
			v.CFrame = v.CFrame*CFrame.Angles(0,0,math.rad(_Tune.RToe))
		else
			v.CFrame = v.CFrame*CFrame.Angles(0,0,math.rad(-_Tune.RToe))
		end
	end

	for _,a in pairs(WParts) do
		a[1].CFrame=v.CFrame:toWorldSpace(a[2])
	end

	if v.Name=="FL" then
		v.CFrame = v.CFrame*CFrame.Angles(0,math.rad(-_Tune.FCaster),0)
	elseif v.Name=="FR" or v.Name=="F" then
		v.CFrame = v.CFrame*CFrame.Angles(0,math.rad(_Tune.FCaster),0)
	elseif v.Name=="RL" then
		v.CFrame = v.CFrame*CFrame.Angles(0,math.rad(-_Tune.RCaster),0)
	elseif v.Name=="RR" or v.Name=="R" then
		v.CFrame = v.CFrame*CFrame.Angles(0,math.rad(_Tune.RCaster),0)
	end

	local arm=Instance.new("Part",v)
	arm.Name="Arm"
	arm.Anchored=true
	arm.CanCollide=false
	arm.FormFactor=Enum.FormFactor.Custom
	arm.Size=Vector3.new(1,1,1)
	arm.CFrame=(v.CFrame*CFrame.new(0,_Tune.StAxisOffset,0))*CFrame.Angles(-math.pi/2,-math.pi/2,0)
	arm.TopSurface=Enum.SurfaceType.Smooth
	arm.BottomSurface=Enum.SurfaceType.Smooth
	arm.Transparency=1

	local base=arm:Clone()
	base.Parent=v
	base.Name="Base"
	base.CFrame=base.CFrame*CFrame.new(0,1,0)
	base.BottomSurface=Enum.SurfaceType.Hinge

	local axle=arm:Clone()
	axle.Parent=v
	axle.Name="Axle"
	axle.CFrame=CFrame.new(v.Position-((v.CFrame*CFrame.Angles(math.pi/2,0,0)).lookVector*((v.Size.x/2)+(axle.Size.x/2))),v.Position)*CFrame.Angles(0,math.pi,0)
	axle.BackSurface=Enum.SurfaceType.Hinge

	if v.Name=="F" or v.Name=="R" then
		local axle2=arm:Clone()
		axle2.Parent=v
		axle2.Name="Axle"
		axle2.CFrame=CFrame.new(v.Position+((v.CFrame*CFrame.Angles(math.pi/2,0,0)).lookVector*((v.Size.x/2)+(axle2.Size.x/2))),v.Position)*CFrame.Angles(0,math.pi,0)
		axle2.BackSurface=Enum.SurfaceType.Hinge
		MakeWeld(arm,axle2)
	end

	MakeWeld(car.DriveSeat,base)
	if v.Parent.Name == "RL" or v.Parent.Name == "RR" or v.Name=="R" then
		MakeWeld(car.DriveSeat,arm)
	end

	MakeWeld(arm,axle)

	arm:MakeJoints()
	axle:MakeJoints()

	if v:FindFirstChild("Fixed")~=nil then
		ModelWeld(v.Fixed,axle)
	end

	if v:FindFirstChild("Parts")~=nil then
		ModelWeld(v.Parts,v)
	end

	if v:FindFirstChild("Steer") then
		v:FindFirstChild("Steer"):Destroy()
	end

	local gyro=Instance.new("BodyGyro",v)
	gyro.Name="Stabilizer"
	if v.Name=="FL" or v.Name=="FR"  or v.Name=="F" then
		gyro.D=_Tune.FGyroD
		gyro.MaxTorque=_Tune.FGyroMaxTorque
		gyro.P=_Tune.FGyroP
	else
		gyro.D=_Tune.RGyroD
		gyro.MaxTorque=_Tune.RGyroMaxTorque
		gyro.P=_Tune.RGyroP
	end

	if v.Name=="FL" or v.Name=="FR" or v.Name=="F" then
		local steer=Instance.new("BodyGyro",arm)
		steer.Name="Steer"
		steer.P=_Tune.SteerP
		steer.D=_Tune.SteerD
		steer.MaxTorque=Vector3.new(0,_Tune.SteerMaxTorque,0)
		steer.cframe=base.CFrame
	else
		MakeWeld(base,axle,"Weld")
	end

	local AV=Instance.new("BodyAngularVelocity",v)
	AV.Name="#AV"
	AV.angularvelocity=Vector3.new(0,0,0)
	AV.maxTorque=Vector3.new(_Tune.PBrakeForce,0,_Tune.PBrakeForce)
	AV.P=1e9
end

for i,v in pairs(script:GetChildren()) do
	if v:IsA("ModuleScript") then
		require(v)
	end
end

wait()
ModelWeld(car.Body,car.DriveSeat)

local flipG = Instance.new("BodyGyro",car.DriveSeat)
flipG.Name = "Flip"
flipG.D = 0
flipG.MaxTorque = Vector3.new(0,0,0)
flipG.P = 0

wait()

UnAnchor(car)

script.Parent["A-Chassis Interface"].Car.Value=car
for i,v in pairs(script.Parent.Plugins:GetChildren()) do
	for _,a in pairs(v:GetChildren()) do
		if a:IsA("RemoteEvent") or a:IsA("RemoteFunction") then
			a.Parent=car
			for _,b in pairs(a:GetChildren()) do
				if b:IsA("Script") then b.Disabled=false end
			end
		end
	end
	v.Parent = script.Parent["A-Chassis Interface"]
end
script.Parent.Plugins:Destroy()

car.DriveSeat.ChildAdded:connect(function(child)
	if child.Name=="SeatWeld" and child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
		local p=game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		car.DriveSeat:SetNetworkOwner(p)
		local g=script.Parent["A-Chassis Interface"]:Clone()
		g.Parent=p.PlayerGui
	end
end)
car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name=="SeatWeld" and child:IsA("Weld") then
		for i,v in pairs(car.DriveSeat:GetChildren()) do
			if v:IsA("Sound") then v:Stop() end
		end
		if car.DriveSeat:FindFirstChild("Flip")~=nil then
			car.DriveSeat.Flip.MaxTorque = Vector3.new()
		end
		for i,v in pairs(car.Wheels:GetChildren()) do
			if v:FindFirstChild("#AV")~=nil then
				if v["#AV"].AngularVelocity.Magnitude>0 then
					v["#AV"].AngularVelocity = Vector3.new()
					v["#AV"].MaxTorque = Vector3.new()
				end
			end
		end
	end
end)

ver = require(script.Parent.README)


Prompt: --[This script makes the movement that a conveyor would do.]

Response:
if script.Disabled == false then
	local conveyor = script.Parent
	conveyor.Velocity = conveyor.CFrame:vectorToWorldSpace(Vector3.new(0, 0, -conveyor.Configuration.Speed.Value))
end


Prompt: -- Mimic roblox menu when opened and closed

Response:
guiService.MenuClosed:Connect(function()
	menuOpen = false
	if not IconController.controllerModeEnabled then
		IconController.setTopbarEnabled(IconController.topbarEnabled,false)
	end
end)
guiService.MenuOpened:Connect(function()
	menuOpen = true
	IconController.setTopbarEnabled(false,false)
end)

bindCamera()

return IconController


Prompt:
--[[

PhysicsSolver:CreateSolver(CharacterClass)
	Creates a new physics solver from CharacterClass
	RETURNS: PhysicsSolverClass

CLASS PhysicsSolverClass
	PhysicsSolverClass:SetNewContext(Pos)
		Sets the next position to override ray casting. Used for teleporting
	PhysicsSolverClass:SetEnabled(Enabled)
		Sets whether the solver is enabled or disabled
	PhysicsSolverClass:Disconnect()
		Disconnects all events

--]]

Response:
local PhysicsSolver = {}

local Configuration = require(script.Parent.Parent:WaitForChild("Configuration"))
local GRAVITY = Configuration.PhysicsSolver.GRAVITY
local USE_FALLING_SIMULATION = Configuration.PhysicsSolver.USE_FALLING_SIMULATION
local DESTROY_HEIGHT = game:GetService("Workspace").FallenPartsDestroyHeight

local RunService = game:GetService("RunService")
local Util = require(script.Parent:WaitForChild("Util"))

local V3new = Vector3.new

function PhysicsSolver:CreateSolver(CharacterClass)
	local Enabled = true
	local PhysicsSolverClass = {}
	local Head = CharacterClass.CharacterModel:WaitForChild("Head")
	local LeftFoot,RightFoot
	local function UpdateFeet()
		LeftFoot = CharacterClass.CharacterModel:FindFirstChild("LeftFoot")
		RightFoot = CharacterClass.CharacterModel:FindFirstChild("RightFoot")
	end
	UpdateFeet()

	local OverridePos
	local LastY,LastTargetY = 0,0
	function PhysicsSolverClass:SetNewContext(NewOverridePos)
		OverridePos = NewOverridePos + V3new(0,4,0)
		LastY = OverridePos.Y
	end

	function PhysicsSolverClass:SetEnabled(NewEnabled)
		Enabled = NewEnabled
	end

	local DownDirection500 = V3new(0,-500,0)
	if GRAVITY > 0 then
		DownDirection500 = V3new(0,500,0)
	end

	local FootOffset = Vector3.new(0,2,0)
	local SolverEvent
	if USE_FALLING_SIMULATION then
		local Velocity = 0

		SolverEvent = RunService.RenderStepped:Connect(function(DeltaTime)
			if Enabled then
				local EndPart,BottomPos
				if OverridePos then
					EndPart,BottomPos = Util:FindCollidablePartOnRay(OverridePos,DownDirection500,CharacterClass.CharacterModel)
					UpdateFeet()
				elseif LeftFoot and RightFoot then
					local LeftFootPos = LeftFoot.Position + FootOffset
					local RightFootPos = RightFoot.Position + FootOffset

					local LeftEndPart,LeftBottomPos = Util:FindCollidablePartOnRay(LeftFootPos,DownDirection500,CharacterClass.CharacterModel)
					local RightEndPart,RightBottomPos = Util:FindCollidablePartOnRay(RightFootPos,DownDirection500,CharacterClass.CharacterModel)

					if LeftBottomPos.Y > RightBottomPos.Y then
						EndPart,BottomPos = LeftEndPart,LeftBottomPos
					else
						EndPart,BottomPos = RightEndPart,RightBottomPos
					end
				elseif LeftFoot then
					local LeftFootPos = LeftFoot.Position + FootOffset
					EndPart,BottomPos = Util:FindCollidablePartOnRay(LeftFootPos,DownDirection500,CharacterClass.CharacterModel)
					UpdateFeet()
				elseif RightFoot then
					local RightFootPos = RightFoot.Position + FootOffset
					EndPart,BottomPos = Util:FindCollidablePartOnRay(RightFootPos,DownDirection500,CharacterClass.CharacterModel)
					UpdateFeet()
				else
					local HeadPos = Head.Position
					EndPart,BottomPos = Util:FindCollidablePartOnRay(HeadPos,DownDirection500,CharacterClass.CharacterModel)
					UpdateFeet()
				end

				local EndY = BottomPos.Y
				Velocity = Velocity + (GRAVITY * DeltaTime)
				local DestinationY = LastY + Velocity

				if DestinationY > EndY then
					LastY = DestinationY
				else
					Velocity = 0
					LastY = EndY
				end
				CharacterClass:SetWorldYOffset(LastY)

				if OverridePos then
					OverridePos = nil
				end

				if LastY < DESTROY_HEIGHT then
					Enabled = false
					CharacterClass.Humanoid.Health = 0
				end
			end
		end)
	else
		SolverEvent = RunService.RenderStepped:Connect(function()
			if Enabled then
				local EndPart,BottomPos
				if OverridePos then
					EndPart,BottomPos = Util:FindCollidablePartOnRay(OverridePos,DownDirection500,CharacterClass.CharacterModel)
					UpdateFeet()
				elseif LeftFoot and RightFoot then
					local LeftFootPos = LeftFoot.Position + FootOffset
					local RightFootPos = RightFoot.Position  + FootOffset

					local LeftEndPart,LeftBottomPos = Util:FindCollidablePartOnRay(LeftFootPos,DownDirection500,CharacterClass.CharacterModel)
					local RightEndPart,RightBottomPos = Util:FindCollidablePartOnRay(RightFootPos,DownDirection500,CharacterClass.CharacterModel)

					if LeftBottomPos.Y > RightBottomPos.Y then
						EndPart,BottomPos = LeftEndPart,LeftBottomPos
					else
						EndPart,BottomPos = RightEndPart,RightBottomPos
					end
				elseif LeftFoot then
					local LeftFootPos = LeftFoot.Position + FootOffset
					EndPart,BottomPos = Util:FindCollidablePartOnRay(LeftFootPos,DownDirection500,CharacterClass.CharacterModel)
					UpdateFeet()
				elseif RightFoot then
					local RightFootPos = RightFoot.Position + FootOffset
					EndPart,BottomPos = Util:FindCollidablePartOnRay(RightFootPos,DownDirection500,CharacterClass.CharacterModel)
					UpdateFeet()
				else
					local HeadPos = Head.Position
					EndPart,BottomPos = Util:FindCollidablePartOnRay(HeadPos,DownDirection500,CharacterClass.CharacterModel)
					UpdateFeet()
				end

				if EndPart then
					LastY = BottomPos.Y
				end
				CharacterClass:SetWorldYOffset(LastY)

				if OverridePos then
					OverridePos = nil
				end

				if LastY < DESTROY_HEIGHT then
					Enabled = false
					CharacterClass.Humanoid.Health = 0
				end
			end
		end)
	end

	function PhysicsSolverClass:Disconnect()
		SolverEvent:Disconnect()
	end

	return PhysicsSolverClass
end

return PhysicsSolver


Prompt: ----------------------This is just an example-----------------------------

Response:
end

function onKeyPressG()
	print("G is pressed")
	PageLayout:JumpTo(script.Parent.Grenade)


Prompt: --if another player picks up the pizza during the tutorial, give it to the persion in the tutorial

Response:
local Handle = script.Parent.Handle
script.Parent.Equipped:connect(function()
	local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
	if player and Handle:FindFirstChild("Tutorial") and Handle.Tutorial.Value and Handle.Tutorial.Value ~= player then
		wait()
		script.Parent.Parent = Handle.Tutorial.Value.Character
	end
end)


Prompt: --This script only activates when the ClickDetector's activation distance is over 0

Response:
function onClicked(p)
	script.Parent.Parent.Open.Transparency = 0 --Open the trap
	script.Parent.Parent.Close.Transparency = 1
	script.Parent.Captured.Value = false
	script.Parent.ClickDetector.MaxActivationDistance = 0 --Make it so that you can't click it
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)


Prompt: -- уничтожаем огонь и скрипт

Response:
script.Parent.Fire:Destroy()
script:Destroy()


Prompt: --Weld stuff here

Response:
car.DriveSeat.ChildAdded:connect(function(child)
	if child.Name=="SeatWeld" and child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
		child.C0=CFrame.new(0,-.4,0)*CFrame.fromEulerAnglesXYZ(-(math.pi/2),0,0)
	end
end)


Prompt:
--[=[
	@within Gamepad
	@prop GamepadChanged Signal<gamepad: Enum.UserInputType>
	@readonly
	Fires when the active gamepad switches. Internally, the gamepad
	object will always wrap around the active gamepad, so nothing
	needs to be changed.

	```lua
	gamepad.GamepadChanged:Connect(function(newGamepad: Enum.UserInputType)
		print("Active gamepad changed to:", newGamepad)
	end)
	```
]=]


Prompt:
-------------------
---[[Variables]]---
-------------------

Response:
local module = {}

local TweenService = game:GetService("TweenService")


Prompt: --//Remote Functions\\--

Response:
fire.OnServerEvent:Connect(function(player, mouseHit)
	local character = player.Character
	local humanoid = character:FindFirstChild("Humanoid")
	local weaponAccuracy = Vector3.new(math.random(-accuracy.Value * 2, accuracy.Value * 2), math.random(-accuracy.Value * 2, accuracy.Value * 2), math.random(-accuracy.Value * 2, accuracy.Value * 2))

	if humanoid and humanoid ~= 0 then
		local projectile = Instance.new("Part", workspace)

			local trail = Instance.new("Trail", projectile)
			trail.FaceCamera = true
			trail.Lifetime = 0.3
			trail.MinLength = 0.15
			trail.LightEmission = 0.25

			local attachment0 = Instance.new("Attachment", projectile)
			attachment0.Position = Vector3.new(0.35, 0, 0)
			attachment0.Name = "Attachment1"
			local attachment1 = Instance.new("Attachment", projectile)
			attachment1.Position = Vector3.new(-0.35, 0, 0)
			attachment1.Name = "Attachment1"

			trail.Attachment0 = attachment0
			trail.Attachment1 = attachment1

		projectile.Name = "Bullet"
		projectile.BrickColor = BrickColor.new("Smoky gray")
		projectile.Shape = "Ball"
		projectile.Material = Enum.Material.Metal
		projectile.TopSurface = 0
		projectile.BottomSurface = 0
		projectile.Size = Vector3.new(1, 1, 1)
		projectile.Transparency = 1
		projectile.CFrame = CFrame.new(muzzle.CFrame.p, mouseHit.p)
		projectile.CanCollide = false

			local transparencyPoints = {}
			local startColor = Color3.new(255, 255, 0)
			local endColor = Color3.new(213, 115, 61)

			table.insert(transparencyPoints, NumberSequenceKeypoint.new(0, 1))
			table.insert(transparencyPoints, NumberSequenceKeypoint.new(0.25, 0))
			table.insert(transparencyPoints, NumberSequenceKeypoint.new(1, 1))

			local determinedTransparency = NumberSequence.new(transparencyPoints)
			local determinedColors = ColorSequence.new(startColor, endColor)

			trail.Transparency = determinedTransparency
			trail.Color = determinedColors

			local bodyVelocity = Instance.new("BodyVelocity", projectile)
			bodyVelocity.MaxForce = Vector3.new(9e9, 9e9, 9e9)
			bodyVelocity.Velocity = (mouseHit.lookVector * velocity.Value) + weaponAccuracy

		debris:AddItem(projectile, 20)

		projectile.Touched:Connect(function(hit)
			local eHumanoid = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
			local damage = math.random(minDamage.Value, maxDamage.Value)
			if not eHumanoid and not hit.Anchored and not hit:IsDescendantOf(character) then

				projectile:Destroy()
			elseif eHumanoid and eHumanoid ~= humanoid and eHumanoid.Health > 0 and hit ~= projectile then

				if hit.Name == "Head" or hit:IsA("Hat") then
					damage = damage * 10.5
				end

				local criticalPoint = maxDamage.Value
				DamageAndTagHumanoid(player, eHumanoid, damage)

				if showDamageText then
					DynamicText(damage, criticalPoint, eHumanoid)
				else
				end

				projectile:Destroy()
			elseif hit.CanCollide == true and not hit:IsDescendantOf(player.Character) and hit.Anchored == true then

				projectile:Destroy()
			end
		end)

		handle.Fire:Play()
		muzzleEffect.Visible = true
		muzzleEffect.Rotation = math.random(-360, 360)

		delay(0.1, function()
			muzzleEffect.Visible = false
		end)

	end
end)

activateSpecial.OnServerEvent:Connect(function(player)
	accuracy.Value, fireRate.Value = accuracy.Value / 2, fireRate.Value / 2
	minDamage.Value, maxDamage.Value = minDamage.Value / 2, maxDamage.Value / 2

	spawn(function()
		local chargeSound = Instance.new("Sound", player.PlayerGui)
		chargeSound.Name = "ChargeSound"
		chargeSound.SoundId = "rbxassetid://163619849"
		chargeSound:Play()

		chargeSound.Ended:Connect(function() chargeSound:Destroy() end)

		local sparkles = Instance.new("Sparkles", handle)
		sparkles.SparkleColor = Color3.fromRGB(255, 236, 21)

		local activatedGui = Instance.new("ScreenGui", player.PlayerGui)
		activatedGui.Name = "SpecialActivated"
			local textLabel = Instance.new("TextLabel", activatedGui)
			textLabel.TextColor3 = Color3.fromRGB(0, 180, 30)
			textLabel.Text = "Trigger Happy activated!"
			textLabel.Font = Enum.Font.SourceSans
			textLabel.TextScaled = true
			textLabel.TextStrokeTransparency = 0
			textLabel.Size = UDim2.new(0, 300, 0, 50)
			textLabel.Position = UDim2.new(2.5, 0, 0.15, -10)
			textLabel.BackgroundTransparency = 1
			textLabel:TweenPosition(UDim2.new(0.5, -(textLabel.Size.X.Offset / 2),  0.1, -10), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 1)

		debris:AddItem(sparkles, specialDuration.Value)
		debris:AddItem(chargeSound, 3)

		wait(3)
		TextEffects(textLabel, 200, Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 1)
	end)

	for i = specialDuration.Value, 0, -1 do
		wait(1)
		print("Special activated: "..i)
	end

	accuracy.Value, fireRate.Value = accuracy.Value * 5, fireRate.Value * 10
	minDamage.Value, maxDamage.Value = minDamage.Value * 4, maxDamage.Value * 8
	activateSpecial:FireClient(player)
end)


Prompt: --Made by Stickmasterluke

Response:
local sp=script.Parent

damage=40
cooldown=.30

debris=game:GetService("Debris")
check=true

function waitfor(parent,name)
	while true do
		local child=parent:FindFirstChild(name)
		if child~=nil then
			return child
		end
		wait()
	end
end

local handle=waitfor(sp,"Handle")
local debris=game:GetService("Debris")

function randomcolor()
	if handle then
		local m=handle:FindFirstChild("Mesh")
		if m~=nil then
			m.VertexColor=Vector3.new(math.random(1,2),math.random(1,2),math.random(1,2))*.5
		end
	end
end

function onButton1Down(mouse)
	if check then
		check=false
		mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
		local h=sp.Parent:FindFirstChild("Humanoid")
		local t=sp.Parent:FindFirstChild("Torso")
		local anim=sp:FindFirstChild("RightSlash")
		if anim and t and h then
			theanim=h:LoadAnimation(anim)
			theanim:Play(nil,nil,1.5)
			if theanim and h.Health>0 then
				local sound=sp.Handle:FindFirstChild("SlashSound")
				if sound then
					sound:Play()
				end
				wait(.25)
				handle.Transparency=1
				local p=handle:clone()
				p.Name="Effect"
				p.CanCollide=false
				p.Transparency=1
				p.Script.Disabled=false
				local tag=Instance.new("ObjectValue")
				tag.Name="creator"
				tag.Value=h
				tag.Parent=p
				p.RotVelocity=Vector3.new(0,0,0)
				p.Velocity=(mouse.Hit.p-p.Position).unit*300+Vector3.new(0,60,0)
				p.CFrame=CFrame.new(handle.Position,mouse.Hit.p)*CFrame.Angles(-math.pi/2,0,0)
				debris:AddItem(p,20+math.random()*5)
				p.Parent=game.Workspace
			end
		end
		wait(cooldown-.25)
		mouse.Icon="rbxasset://textures\\GunCursor.png"
		randomcolor()
		handle.Transparency=1
		check=true
	end
end

sp.Equipped:connect(function(mouse)
	if mouse==nil then
		print("Mouse not found")
		return
	end
	equipped=true
	mouse.Icon="rbxasset://textures\\GunCursor.png"
	mouse.Button1Down:connect(function()
		onButton1Down(mouse)
	end)
end)

sp.Unequipped:connect(function()
	equipped=false
	handle.Transparency=1
	randomcolor()
end)