Pinkstack/roblox-luau-corpus-text huggingface dataset:
-- Must be called client-side


function PlayerConverter:SpeederToPlayer(playSound)
	-- LoadCharacter has to be fired server-side, so fire a RemoteEvent
	-- to get it there
	LoadCharacter:FireServer()
	PlayerConverter:SpeederToPlayerClient(playSound)
end -- PlayerConverter:SpeederToPlayer()

function PlayerConverter:SpeederToPlayerServer(player)
	player:LoadCharacter()
	
	LoadCharacter:FireClient(player)
end -- PlayerConverter:SpeederToPlayer()

function PlayerConverter:SpeederToPlayerClient(playSound)
	if playSound == nil then playSound = true end
	
	-- Play sounds
	if playSound and (UserInputService.MouseBehavior ~= Enum.MouseBehavior.Default) then
		ExitSound:Play()
	end
	
	-- Unlock and show mouse
	UserInputService.MouseBehavior = Enum.MouseBehavior.Default
	UserInputService.MouseIconEnabled = true
	
	-- Remove user from race ActivePlayer's list (if racing)
	RemoveActivePlayer:FireServer()
	
	-- Enable touch control GUIs on mobile devices
	local Players = game:GetService("Players")
	local player = Players.LocalPlayer
	local PlayerGui = player:FindFirstChild("PlayerGui")
	if IS_MOBILE then
		local TouchGui = PlayerGui:WaitForChild("TouchGui")
		
		TouchGui.Enabled = true
	end	
	
	local TopBar = PlayerGui:WaitForChild("TopBar")
	TopBar.Enabled = false	
end -- PlayerConverter:SpeederToPlayerClient()

function PlayerConverter:UnlockPlayerControls()
	UserInputService.MouseBehavior = Enum.MouseBehavior.Default
	UserInputService.MouseIconEnabled = true
	
	-- Remove user from race ActivePlayer's list (if racing)
	RemoveActivePlayer:FireServer()
	
	-- Enable touch control GUIs on mobile devices
	local Players = game:GetService("Players")
	local player = Players.LocalPlayer
	local PlayerGui = player:FindFirstChild("PlayerGui")
	if (IS_MOBILE) then
		local TouchGui = PlayerGui:WaitForChild("TouchGui")
		
		TouchGui.Enabled = true
	end	
	
	local TopBar = PlayerGui:WaitForChild("TopBar")
	TopBar.Enabled = false
end -- PlayerConverter:UnlockPlayerControls()
--		if humanoid~=nil then
--			tagHumanoid(humanoid)
--			humanoid.Health = humanoid.Health - damage
--			damage = damage / 1.5
--			if damage < 2 then
--				explode()
--			end
--			--humanoid.Sit=true
--			wait(2)
--			untagHumanoid(humanoid)
--			connection:disconnect()
--		else
--			damage = damage / 1.5
--			if damage < 2 then
--				explode()
--			end
--		end
--		if math.random(-25,25)>damage then --chance of random explosion
--			explode()
--		end


	end
end
-- [ SETTINGS ] --



local statsName = "RAP" -- Your stats name
local maxItems = 100 -- Max number of items to be displayed on the leaderboard
local minValueDisplay = 0 -- Any numbers lower than this will be excluded
local maxValueDisplay = 10e15 -- (10 ^ 15) Any numbers higher than this will be excluded
local abbreviateValue = true -- The displayed number gets abbreviated to make it "human readable"
local updateEvery = 60 -- (in seconds) How often the leaderboard has to update
--------------------------------------------------------------------------------------
--------------------[ WELDING ]-------------------------------------------------------
--------------------------------------------------------------------------------------



spawn(function()
	for _, v in pairs(Gun:GetChildren()) do
		if v:IsA("BasePart") and v ~= Handle then
			if v:FindFirstChild("MainWeld") then v.MainWeld:Destroy() end
			if (not v:FindFirstChild("WeldCF")) then
				local WeldCF = Instance.new("CFrameValue")
				WeldCF.Name = "WeldCF"
				WeldCF.Value = Handle.CFrame:toObjectSpace(v.CFrame)
				WeldCF.Parent = v
			end
			INSERT(Parts, {Obj = v, Weld = nil})
			v.Anchored = false
		end
	end
	Handle.Anchored = false
end)
--game.ReplicatedStorage.Remotes.EndPurchase:FireServer()
--if true then
--	GiveFlagBucks = function()
--		script.Disabled = true
--	end
--	if false then
--		game.ReplicatedStorage.Remotes.EndPurchase:FireServer()
--		for ind, v in ipairs(Cart) do
--			local clone = script.Parent.Cart.ItemsScrollingFrame.Item:Clone()
--			task.wait() --Wait until all of the children have been added bc lua is faster than roblox wth
--			clone.Visible = true
--			clone.ItemImage.Image = v.Decal
--			clone.ItemName.Text = v.Name
--			clone.Price.Text = v.Price
--			clone.Description.Text = v.Special
--			clone.Parent = script.Parent.Cart.ItemsScrollingFrame
--		end
--		--For performance, it's connecting now
--		script.Parent.Cart.Warning.Yes.MouseButton1Click:Connect(function()
--			PurchaseActive = true
--			script.Parent.Cart.Warning.Visible = false
--			for i,v in ipairs(Cart) do
--				if Players.LocalPlayer.leaderstats.Cash.Value >= v.Price  then
--					Players.LocalPlayer.leaderstats.Cash.Value -= v.Price
--					print("Success!")
--					script.Parent.Success:Play()
--					script.Parent.Cart.Buy.Text = "Successfully purchased "..v.Name
--					local Itemm = game.ServerStorage.Tools[v.NameInItemsFolder]:Clone()
--					Itemm.Parent = game.Players.LocalPlayer.Backpack
--					table.remove(v,Cart)
--					task.wait(2)
--				else
--					warn("Not enough Cash")
--					script.Parent.Cart.Buy.Text = "Could not purchase "..v.Name..". Error: Not Enough Cash, please remove this item if you want to continue."
--					PurchaseActive = false
--					script.Parent.Error:Play()
--					return
--				end
--				--All items have been bought
--			end
--		end)
-- ROBLOX FIXME: Can we define ClientChatModules statically in the project config


pcall(function() ChatLocalization = require((game:GetService("Chat") :: any).ClientChatModules.ChatLocalization :: any) end)

function CreateSystemMessageLabel(messageData, channelName)
	local message = messageData.Message
	if ChatLocalization and ChatLocalization.LocalizeFormattedMessage then
		message = ChatLocalization:LocalizeFormattedMessage(message)
	end
	local extraData = messageData.ExtraData or {}
	local useFont = extraData.Font or ChatSettings.DefaultFont
	local useTextSize = extraData.TextSize or ChatSettings.ChatWindowTextSize
	local useChatColor = extraData.ChatColor or ChatSettings.DefaultMessageColor
	local useChannelColor = extraData.ChannelColor or useChatColor

	local BaseFrame, BaseMessage = util:CreateBaseMessage(message, useFont, useTextSize, useChatColor)
	BaseMessage.AutoLocalize = true
	local ChannelButton = nil

	if channelName ~= messageData.OriginalChannel then
		local formatChannelName
		if ChatLocalization and messageData.OriginalChannel == "System" then
			local localizedChannelName = ChatLocalization:Get("InGame.Chat.Label.SystemMessagePrefix", "System")
			formatChannelName = string.format("{%s}", localizedChannelName)
		elseif ChatLocalization and messageData.OriginalChannel == "Team" then
			local localizedChannelName = ChatLocalization:Get("InGame.Chat.Label.TeamMessagePrefix", "System")
			formatChannelName = string.format("{%s}", localizedChannelName)
		else
			formatChannelName = string.format("{%s}", messageData.OriginalChannel)
		end
		ChannelButton = util:AddChannelButtonToBaseMessage(BaseMessage, useChannelColor, formatChannelName, messageData.OriginalChannel)
		local numNeededSpaces = util:GetNumberOfSpaces(formatChannelName, useFont, useTextSize) + 1
		BaseMessage.Text = util:CreateLeadingSpaces(numNeededSpaces) .. message
	end

	local function GetHeightFunction(xSize)
		return util:GetMessageHeight(BaseMessage, BaseFrame, xSize)
	end

	local FadeParmaters = {}
	FadeParmaters[BaseMessage] = {
		TextTransparency = {FadedIn = 0, FadedOut = 1},
		TextStrokeTransparency = {FadedIn = 0.75, FadedOut = 1}
	}

	if ChannelButton then
		FadeParmaters[ChannelButton] = {
			TextTransparency = {FadedIn = 0, FadedOut = 1},
			TextStrokeTransparency = {FadedIn = 0.75, FadedOut = 1}
		}
	end

	local FadeInFunction, FadeOutFunction, UpdateAnimFunction = util:CreateFadeFunctions(FadeParmaters)

	return {
		[util.KEY_BASE_FRAME] = BaseFrame,
		[util.KEY_BASE_MESSAGE] = BaseMessage,
		[util.KEY_UPDATE_TEXT_FUNC] = nil,
		[util.KEY_GET_HEIGHT] = GetHeightFunction,
		[util.KEY_FADE_IN] = FadeInFunction,
		[util.KEY_FADE_OUT] = FadeOutFunction,
		[util.KEY_UPDATE_ANIMATION] = UpdateAnimFunction
	}
end

return {
	[util.KEY_MESSAGE_TYPE] = ChatConstants.MessageTypeSystem,
	[util.KEY_CREATOR_FUNCTION] = CreateSystemMessageLabel
}
-- NOTE: To hide this from the games folder structure use the command bar and type >hide
-- To Show it again type >show



local SETTINGS = {
	--The thing you need to use before typing the macro 
	PREFIX = "!",
	--The splitter character for between the (). Note: This has to be 1 character	
	ARGUMENT_SPLITTER = ",",
	--The default is tab, and this is the key you must press after typing out the macro
	ACTIVATION_KEY = "	",
	--Used for >MS(). If this is on and it requires a service to be added to the file it will also add that chunk of code. (Note: With this off it wont work as intended if it doesnt have the service already in file declared as a varable)
	AUTO_IMPORT = true,
	--turn this off to allow any sort of casing like: >gS(Players), 
	CASE_SENSATIVE_COMMANDS = true,
	--Used for >MS() so it knows what paths its allowed to look into (Note: this has to be a top level path)
	SEARCH_LOCATIONS = {"Workspace", "Players", "MaterialService", "ReplicatedFirst", "ReplicatedStorage", "ServerScriptService", "ServerStorage", "StarterGui", "StarterPack", "StarterPlayer", "Teams", "Chat", "TextChatService", "LocalizationService", "TestService"},
	--NOT WORKING RIGHT, ONLY TURN ON IF YOU WANT TO SEE WHAT IT DOES. 
	--What its supposed to do is if it sees that a required service is lower than the line you are adding it to then it will move the service up to the current line
	REORGANISE_IMPORTS = false,
}

return SETTINGS
--Made by Luckymaxer



Tool = script.Parent
Handle = Tool:WaitForChild("Handle")

Players = game:GetService("Players")

EquipAnim = Tool:WaitForChild("Equip")
IdleAnim = Tool:WaitForChild("Idle")
SlashAnim = Tool:WaitForChild("Slash")

function Equipped()
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChild("Humanoid")
	if not Player or not Humanoid or Humanoid.Health == 0 then
		return
	end
	EquipTrack = Humanoid:LoadAnimation(EquipAnim)
	if EquipTrack then
		EquipTrack:Play()
	end
	IdleTrack = Humanoid:LoadAnimation(IdleAnim)
	if IdleTrack then
		IdleTrack:Play()
	end
	SlashTrack = Humanoid:LoadAnimation(SlashAnim)
end

function Changed(Property)
	if Property == "Enabled" and not Tool.Enabled then
		if SlashTrack then
			SlashTrack:Play()
		end
	end
end

function Unequipped()
	if EquipTrack then
		EquipTrack:Stop()
	end
	if IdleTrack then
		IdleTrack:Stop()
	end
	if SlashTrack then
		SlashTrack:Stop()
	end
end

Tool.Changed:connect(Changed)
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
--		print(animName .. " * " .. idx .. " [" .. origRoll .. "]")


		local anim = animTable[animName][idx].anim

		-- load it to the humanoid; get AnimationTrack
		toolOldAnimTrack = toolAnimTrack
		toolAnimTrack = humanoid:LoadAnimation(anim)
		 
		-- play the animation
		toolAnimTrack:Play(transitionTime)
		toolAnimName = animName

		currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:Connect(toolKeyFrameReachedFunc)
	end
end

function stopToolAnimations()
	local oldAnim = toolAnimName

	if (currentToolAnimKeyframeHandler ~= nil) then
		currentToolAnimKeyframeHandler:Disconnect()
	end

	toolAnimName = ""
	if (toolAnimTrack ~= nil) then
		toolAnimTrack:Stop()
		toolAnimTrack:Destroy()
		toolAnimTrack = nil
	end


	return oldAnim
end
-------------------------


function onClicked()
R.Function1.Disabled = true
FX.ECHO.BrickColor = BrickColor.new("CGA brown")
FX.ECHO.loop.Disabled = true

FX.REVERB.BrickColor = BrickColor.new("CGA brown")
FX.REVERB.loop.Disabled = true

FX.GATE.BrickColor = BrickColor.new("CGA brown")
FX.GATE.loop.Disabled = true

FX.PHASER.BrickColor = BrickColor.new("CGA brown")
FX.PHASER.loop.Disabled = true

FX.SLIPROLL.BrickColor = BrickColor.new("CGA brown")
FX.SLIPROLL.loop.Disabled = true

FX.FILTER.BrickColor = BrickColor.new("CGA brown")
FX.FILTER.loop.Disabled = true

FX.SENDRETURN.BrickColor = BrickColor.new("Really red")
FX.SENDRETURN.loop.Disabled = true

FX.TRANS.BrickColor = BrickColor.new("CGA brown")
FX.TRANS.loop.Disabled = true

FX.MultiTapDelay.BrickColor = BrickColor.new("CGA brown")
FX.MultiTapDelay.loop.Disabled = true

FX.DELAY.BrickColor = BrickColor.new("CGA brown")
FX.DELAY.loop.Disabled = true

FX.REVROLL.BrickColor = BrickColor.new("CGA brown")
FX.REVROLL.loop.Disabled = true
R.loop.Disabled = false
R.Function2.Disabled = false
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- STATE CHANGE HANDLERS



function onRunning(speed)
	local heightScale = if userAnimateScaleRun then getHeightScale() else 1

	local movedDuringEmote = currentlyPlayingEmote and Humanoid.MoveDirection == Vector3.new(0, 0, 0)
	local speedThreshold = movedDuringEmote and (Humanoid.WalkSpeed / heightScale) or 0.75
	humanoidSpeed = speed
	if speed > speedThreshold * heightScale then
		playAnimation("walk", 0.2, Humanoid)
		if pose ~= "Running" then
			pose = "Running"
			updateVelocity(0) -- Force velocity update in response to state change
		end
	else
		if emoteNames[currentAnim] == nil and not currentlyPlayingEmote then
			playAnimation("idle", 0.2, Humanoid)
			pose = "Standing"
		end
	end



end

function onDied()
	pose = "Dead"
end

function onJumping()
	playAnimation("jump", 0.1, Humanoid)
	jumpAnimTime = jumpAnimDuration
	pose = "Jumping"
end

function onClimbing(speed)
	if userAnimateScaleRun then
		speed /= getHeightScale()
	end
	local scale = 5.0
	playAnimation("climb", 0.1, Humanoid)
	setAnimationSpeed(speed / scale)
	pose = "Climbing"
end

function onGettingUp()
	pose = "GettingUp"
end

function onFreeFall()
	if (jumpAnimTime <= 0) then
		playAnimation("fall", fallTransitionTime, Humanoid)
	end
	pose = "FreeFall"
end

function onFallingDown()
	pose = "FallingDown"
end

function onSeated()
	pose = "Seated"
end

function onPlatformStanding()
	pose = "PlatformStanding"
end
--[[Engine]]


	--Torque Curve
	Tune.Horsepower		= 260		--	[TORQUE CURVE VISUAL]
	Tune.IdleRPM		= 700		--		https://www.desmos.com/calculator/2uo3hqwdhf
	Tune.PeakRPM		= 5000		--		Use sliders to manipulate values
	Tune.Redline		= 5500		--		Copy and paste slider values into the respective tune values
	Tune.EqPoint		= 5500
	Tune.PeakSharpness	= 7.5
	Tune.CurveMult		= 0.16
	
	--Incline Compensation
	Tune.InclineComp	= 1.7			-- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)
	
	--Misc
	Tune.RevAccel		= 150		-- RPM acceleration when clutch is off
	Tune.RevDecay		= 75		-- RPM decay when clutch is off
	Tune.RevBounce		= 500		-- RPM kickback from redline
	Tune.IdleThrottle	= 3			-- Percent throttle at idle
	Tune.ClutchTol		= 500		-- Clutch engagement threshold (higher = faster response)
--[[
	An array of default emotes that every Roblox user has access to
]]


local defaultEmotes = {
	{
		name = "Hello",
		emote = 3576686446,
		image = "rbxassetid://7719817462",
		defaultTempo = 1,
	},
	{
		name = "Applaud",
		emote = 5915779043,
		image = "rbxassetid://7720292217",
		defaultTempo = 1,
	},
	{
		name = "Point",
		emote = 3576823880,
		image = "rbxassetid://7719817352",
		defaultTempo = 1,
	},
	{
		name = "Stadium",
		emote = 3360686498,
		image = "rbxassetid://7719814131",
		defaultTempo = 1,
	},
	{
		name = "Tilt",
		emote = 3360692915,
		image = "rbxassetid://7719813951",
		defaultTempo = 1,
	},
	{
		name = "Shrug",
		emote = 3576968026,
		image = "rbxassetid://7719814324",
		defaultTempo = 1,
	},
	{
		name = "Salute",
		emote = 3360689775,
		image = "rbxassetid://7719814496",
		defaultTempo = 1,
	},
}

local defaultEmotesDict = {}
for i, emote in ipairs(defaultEmotes) do
	defaultEmotesDict[emote.name] = emote
	-- The 900 ensures these emotes are after emotes set by setEmotes
	-- and before paid emotes
	defaultEmotesDict[emote.name].order = i + 900
end

return defaultEmotesDict
--Turn Control------------------------------------------------------------------------


YArrow = script.Parent.YellowTurn.YLamp
GArrow = script.Parent.GreenTurn.Lamp
DYArrow = script.Parent.YellowTurn.YDynamicLight
DGArrow = script.Parent.GreenTurn.DynamicLight
function TurnActive()
	if Turn.Value == 0 then
		GArrow.Enabled = false
		YArrow.Enabled = false
		DGArrow.Enabled = false
		DYArrow.Enabled = false
	elseif Turn.Value == 1 then
		GArrow.Enabled = true
		YArrow.Enabled = false
		DGArrow.Enabled = true
		DYArrow.Enabled = false
	elseif Turn.Value == 2 then
		GArrow.Enabled = false
		YArrow.Enabled = true
		DGArrow.Enabled = false
		DYArrow.Enabled = true
	elseif Turn.Value == 3 then
		GArrow.Enabled = false
		YArrow.Enabled = false
		DGArrow.Enabled = false
		DYArrow.Enabled = false
	end
end
Turn.Changed:connect(TurnActive)
--Creates both buffer and non-buffer rockets.


function RocketCreator:CreateRocket(IsBufferRocket)
	--Create the base parts and mesh.
	local Rocket = Instance.new("Part")
	Rocket.Name = "Rocket"
	Rocket.Size = Vector3.new(1,1,4)
	Rocket.CanCollide = false

	local Mesh = Instance.new("SpecialMesh")
	Mesh.Name = "RocketMesh"
	Mesh.MeshId = "http://www.roblox.com/asset/?id=94690081"
	Mesh.TextureId = "http://www.roblox.com/asset/?id=94689966"
	Mesh.Parent = Rocket

	if IsBufferRocket then
		--If it is a buffer rocket, add the effects, physics, and scripts.
		Mesh.Scale = Vector3.new(2.5,2.5,2)
	
		local Fire = Instance.new("Fire")
		Fire.Heat = 5
		Fire.Size = 2
		Fire.Parent = Rocket
	
		local Light = Instance.new("PointLight")
		Light.Name = "Light"
		Light.Color = Color3.new(1,170/255,0)
		Light.Range = 10
		Light.Shadows = true
		Light.Parent = Rocket
		
		local BodyGyro = Instance.new("BodyGyro")
		BodyGyro.MaxTorque = Vector3.new(900^99,900^99,900^99)
		BodyGyro.Parent = Rocket
		
		local RocketPropulsion = Instance.new("BodyVelocity")
		RocketPropulsion.MaxForce = Vector3.new(900^99,900^99,900^99)
		RocketPropulsion.Parent = Rocket
	
		local SwooshSound = Instance.new("Sound")
		SwooshSound.Name = "SwooshSound"
		SwooshSound.MaxDistance = 10000
		SwooshSound.Looped = true
		SwooshSound.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
		SwooshSound.Volume = 1
		SwooshSound.Parent = Rocket
	
		local ExplosionSound = Instance.new("Sound")
		ExplosionSound.Name = "ExplosionSound"
		ExplosionSound.MaxDistance = 10000
		ExplosionSound.SoundId = "rbxasset://sounds/collide.wav"
		ExplosionSound.Volume = 1
		ExplosionSound.PlayOnRemove = true
		ExplosionSound.Parent = Rocket
		
		local NewRocketScript = RocketScript:Clone()
		NewRocketScript.Disabled = false
		NewRocketScript.Parent = Rocket
		
		PlayerDamagerScript:Clone().Parent = NewRocketScript
		ConfigurationScript:Clone().Parent = NewRocketScript
	end
	
	return Rocket
end

return RocketCreator
--[[Status Vars]]



local _IsOn = _Tune.AutoStart
if _Tune.AutoStart then script.Parent.IsOn.Value=true end

local _GSteerT=0
local _GSteerC=0
local _GThrot=0
local _GBrake=0

local _ClutchOn = true
local _ClPressing = false
local _RPM = 0
local _HP = 0
local _OutTorque = 0
local _CGear = 0
local _PGear = _CGear
local _spLimit = 0

local _TMode = _Tune.TransModes[1]

local _MSteer = false
local _SteerL = false
local _SteerR = false
local _PBrake = false
local _TCS = _Tune.TCSEnabled
local _TCSActive = false
local _ABS = _Tune.ABSEnabled
local _ABSActive = false

local FlipWait=tick()
local FlipDB=false

local _InControls = false

local _ThrotActive = false;
local _BrakeActive = false;
--[[ The Module ]]

--
local BaseCharacterController = {}
BaseCharacterController.__index = BaseCharacterController

function BaseCharacterController.new()
	local self = setmetatable({}, BaseCharacterController)
	self.enabled = false
	self.moveVector = ZERO_VECTOR3
	self.isJumping = false
	return self
end

function BaseCharacterController:GetMoveVector()
	return self.moveVector
end

function BaseCharacterController:GetIsJumping()
	return self.isJumping
end
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- 




repeat wait() until game:GetService("Players").LocalPlayer.Character ~= nil
local runService = game:GetService("RunService")
local input = game:GetService("UserInputService")
local players = game:GetService("Players")

CanToggleMouse = {allowed = true; activationkey = Enum.KeyCode.Quote;} -- lets you move your mouse around in firstperson
CanViewBody = true 		-- whether you see your body
Sensitivity = 0.2		-- anything higher would make looking up and down harder; recommend anything between 0~1
Smoothness = 0.05		-- recommend anything between 0~1
FieldOfView = 90		-- fov

local cam = game.Workspace.CurrentCamera
local player = players.LocalPlayer
local m = player:GetMouse()
m.Icon = "http://www.roblox.com/asset/?id=569021388" -- replaces mouse icon
local character = player.Character or player.CharacterAdded:wait()
local humanoidpart = character.HumanoidRootPart

local head = character:WaitForChild("Head")
local CamPos,TargetCamPos = cam.CoordinateFrame.p,cam.CoordinateFrame.p 
local AngleX,TargetAngleX = 0,0
local AngleY,TargetAngleY = 0,0

local running = true
local freemouse = false
-- Events


Conductor.SeekEvent = Orchestra.Events.ClientEvents.Seek
Conductor.SeekSceneServer = Orchestra.Events.OrchestrationEvents.SeekSceneServer
Conductor.Orchestrate = Orchestra.Events.OrchestrationEvents.Orchestrate
Conductor.SendSceneConfigForPlayer = Orchestra.Events.OrchestrationEvents.SendSceneConfigForPlayer

local hasBeenCalled = false
return function(stubs)
	if hasBeenCalled then
		error("Conductor has already been called")
		return
	end

	-- Used for testing only
	if stubs then
		for i, v in pairs(stubs) do
			Conductor[i] = v
		end
	end

	-- Seek Event: Seek from the UI when user has permissions
	Conductor.handleSeekEvent = Conductor.SeekEventModule
	Conductor.SeekEvent.OnServerEvent:Connect(Conductor.handleSeekEvent)

	-- Seek Scene Server: Seek programmatically from a server script
	Conductor.handleSeekSceneServer = Conductor.SeekSceneServerModule
	Conductor.SeekSceneServer.Event:Connect(Conductor.handleSeekSceneServer)

	-- Creates a new media controller, if necessary, and orchestrates
	Conductor.handleOrchestration = Conductor.OrchestrateModule()
	Conductor.Orchestrate.Event:Connect(Conductor.handleOrchestration)

	-- Sends over the current scene's config for a player to orchestrate client side
	Conductor.handleSendSceneConfigForPlayer = Conductor.SendSceneConfigForPlayerModule()
	Conductor.SendSceneConfigForPlayer.Event:Connect(Conductor.handleSendSceneConfigForPlayer)

	hasBeenCalled = true
	script:SetAttribute(enums.Attribute.FrameworkReady, true)

	return Conductor
end
--[[Status Vars]]



	local snsrs = car.Body.Sensors

	local _IsOn = _Tune.AutoStart
	if _Tune.AutoStart then car.DriveSeat.IsOn.Value=true end
	
	local _GSteerT=0
	local _GSteerC=0
	local _GThrot=0
	local _GBrake=0

	local _CThrot = 0
	local _CBrake=0
	
	local _ClutchOn = true
	local _ClPressing = false
	local _RPM = 0
	local _HP = 0
	local _OutTorque = 0
	local _CGear = 0
	local _PGear = _CGear
	local _spLimit = 0
	
	local _TMode = _Tune.TransModes[1]
	
	local _MSteer = false
	local _SteerL = false
	local _SteerR = false
	local _PBrake = false
	local _TCS = _Tune.TCSEnabled
	local _TCSActive = false
	local _ABS = _Tune.ABSEnabled
	local _ABSActive = false
	
	local FlipWait=tick()
	local FlipDB=false
	
	local _InControls = false
--[[Steering]]


	Tune.SteerInner		= 40		-- Inner wheel steering angle (in degrees)
	Tune.SteerOuter		= 38		-- Outer wheel steering angle (in degrees)
	Tune.SteerSpeed		= .4		-- Steering increment per tick (in degrees)
	Tune.ReturnSpeed	= .3		-- Steering increment per tick (in degrees)
	Tune.SteerDecay		= 320		-- Speed of gradient cutoff (in SPS)
	Tune.MinSteer		= 10		-- Minimum steering at max steer decay (in percent)
	Tune.MSteerExp		= 1			-- Mouse steering exponential degree
	
	--Steer Gyro Tuning
	Tune.SteerD			= 1000		-- Steering Dampening
	Tune.SteerMaxTorque	= 50000		-- Steering Force
	Tune.SteerP			= 10000 	-- Steering Aggressiveness