Pinkstack/roblox-luau-corpus-text huggingface dataset:
--[=[
	@param predicate (player: Player, argsFromFire: ...) -> boolean
	@param ... any -- Arguments to pass to the clients (and to the predicate)
	Fires the signal at any clients that pass the `predicate`
	function test. This can be used to fire signals with much
	more control logic.

	:::note Outbound Middleware
	All arguments pass through any outbound middleware (if any)
	before being sent to the clients.
	:::

	:::caution Predicate Before Middleware
	The arguments sent to the predicate are sent _before_ getting
	transformed by any middleware.
	:::

	```lua
	-- Fire signal to players of the same team:
	remoteSignal:FireFilter(function(player)
		return player.Team.Name == "Best Team"
	end)
	```
]=]


function RemoteSignal:FireFilter(predicate: (Player, ...any) -> boolean, ...: any)
	for _, player in ipairs(Players:GetPlayers()) do
		if predicate(player, ...) then
			self._re:FireClient(player, self:_processOutboundMiddleware(nil, ...))
		end
	end
end
--[[
local previousCollisionGroups = {}

local function setCollisionGroup(object)
	if object:IsA("BasePart") then
		previousCollisionGroups[object] = object.CollisionGroupId
		
		PhysicsService:SetPartCollisionGroup(object, playerCollisionGroupName)
	end
end

local function setCollisionGroupRecursive(object)
	setCollisionGroup(object)

	for _, child in ipairs(object:GetChildren()) do
		setCollisionGroupRecursive(child)
	end
end

local function resetCollisionGroup(object)
	local previousCollisionGroupId = previousCollisionGroups[object]
	if not previousCollisionGroupId then return end 

	local previousCollisionGroupName = PhysicsService:GetCollisionGroupName(previousCollisionGroupId)
	if not previousCollisionGroupName then return end

	PhysicsService:SetPartCollisionGroup(object, previousCollisionGroupName)
	previousCollisionGroups[object] = nil
end

local function onCharacterAdded(character)
	setCollisionGroupRecursive(character)

	character.DescendantAdded:Connect(setCollisionGroup)
	character.DescendantRemoving:Connect(resetCollisionGroup)
end

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)
]]
--[[
	Model for sort results in the Catalog.
	{
		items =
		{
			"id": string,
			"type": string
		},

        "keyword":string,
        "previousPageCursor": string,
        "nextPageCursor": string
	}
]]



local SortResults = {}

function SortResults.new()
    local sortResults = {}

	return sortResults
end

function SortResults.mock()
	local self = SortResults.new()

	self.items = {
		id = "",
		type = ""
    }

	self.keyword = ""
	self.previousPageCursor = ""
	self.nextPageCursor = ""

	return self
end

function SortResults.fromSearchItemsDetails(itemDetailsResponse)
	local self = SortResults.new()

	self.items = {}
    for i, itemData in ipairs(itemDetailsResponse.data) do
		self.items[i] = {
			id = tostring(itemData.id),
			type = tostring(itemData.itemType)
		}
    end

	self.keyword = itemDetailsResponse.keyword
	self.previousPageCursor = itemDetailsResponse.previousPageCursor
	self.nextPageCursor = itemDetailsResponse.nextPageCursor

	return self
end

return SortResults
--Motor6D's


local neck = torso.Neck
neck.C1 = CFrame.new(0,0,0)
local leftshoulder = torso["Left Shoulder"]
leftshoulder.C1 = CFrame.new(0,0,0)
local rightshoulder = torso["Right Shoulder"]
rightshoulder.C1 = CFrame.new(0,0,0)
local lefthip = torso["Left Hip"]
lefthip.C1 = CFrame.new(0,0,0)
local righthip = torso["Right Hip"]
righthip.C1 = CFrame.new(0,0,0)
local root = npc.HumanoidRootPart.RootJoint
root.C1 = CFrame.new(0,0,0)
-- check if the player is moving and not climbing


humanoid.Running:Connect(function(speed)
	if humanoid.MoveDirection.Magnitude > 0 and speed > 0 and humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then
		getSoundProperties()
		update()
		currentSound.Playing = true
		currentSound.Looped = true
	else
		currentSound:Stop()
	end
end)
--> FUNCTIONS


script.Parent.Touched:Connect(function(Hit)
	if not Touched then
		if Hit.Parent:FindFirstChildOfClass("Humanoid") then
			Player = game:GetService("Players")[Hit.Parent.Name]
		elseif Hit.Parent.Parent:FindFirstChildOfClass("Humanoid") then
			Player = game:GetService("Players")[Hit.Parent.Parent.Name]
		end
		if Player ~= nil then
			Touched = true
			game:GetService("TeleportService"):TeleportAsync(script.Parent.Parent.GameID.Value, {Player})
			Player = nil
			wait(.2)
			Touched = false
		end
	end
end)
-- Remade by Truenus


wait(0.05)
local car = script.Parent.Parent.Car.Value
local GBrake = script.Parent.Parent.Values.Brake
function on()
		car.Body.Lights.Light.Material=Enum.Material.Neon
		car.Body.Lights.Light.Light.Enabled = true
function off()
		car.Body.Lights.Light.Light.Enabled = false
		car.Body.Lights.Light.Material=Enum.Material.SmoothPlastic
		for i,v in pairs(car.Body.Lights:GetChildren()) do
		end
end
end
function auto()
	if (game.Lighting:GetMinutesAfterMidnight()<390 or game.Lighting:GetMinutesAfterMidnight()>1050) then
		car.Body.Lights.Light.Material=Enum.Material.Neon
		car.Body.Lights.Light.Light.Enabled = true
	else
		car.Body.Lights.Light.Light.Enabled = false
		car.Body.Lights.Light.Material=Enum.Material.SmoothPlastic
	end
end

script.Parent.MouseButton1Click:connect(function()
	if script.Parent.Text == "Lights: Auto" then
		on()
		script.Parent.Text = "Lights: On"
	elseif script.parent.Text == "Lights: On" then
		script.Parent.Text = "Lights: Off"
		off()
	elseif script.parent.Text == "Lights: Off" then
		auto()
		script.Parent.Text = "Lights: Auto"
	end
end)

script.Parent.Parent.Values.Brake.Changed:connect(function()
	for i,v in pairs(car.Body.Lights:GetChildren()) do
		if v.Name=="R" then
			if v.Light.Enabled then
				if GBrake.Value>0 then
					v.Transparency=0
					v.Light.Brightness=12
					v.Light.Range=15
				else
					v.Transparency=.3
					v.Light.Brightness=8
					v.Light.Range=10
				end
			else
				v.Transparency=0
				if GBrake.Value>0 then
					v.Material=Enum.Material.Neon
				else
					v.Material=Enum.Material.SmoothPlastic
				end
			end
		elseif v.Name=="RR" then
			if GBrake.Value>0 then
				v.Material=Enum.Material.Neon
				if v.Light.Enabled then
					v.Transparency=1
				else
					v.Transparency=0
				end
			else
				v.Transparency=1
				if v.Light.Enabled then
					v.Material=Enum.Material.Neon
				else
					v.Material=Enum.Material.SmoothPlastic
				end
			end
		end
	end
end)

game.Lighting.Changed:connect(auto)
auto()
----------------------------------------------------------------------------------------------------
-----------------=[ RECOIL & PRECISAO ]=------------------------------------------------------------
----------------------------------------------------------------------------------------------------


	,VRecoil = {7,10}				--- Vertical Recoil
	,HRecoil = {3,5}				--- Horizontal Recoil
	,AimRecover = .9					---- Between 0 & 1

	,RecoilPunch = .15
	,VPunchBase = 5					--- Vertical Punch
	,HPunchBase = 1.75				--- Horizontal Punch
	,DPunchBase = 1 				--- Tilt Punch | useless

	,AimRecoilReduction = 1 		--- Recoil Reduction Factor While Aiming (Do not set to 0)
	,PunchRecover = 0.2
	,MinRecoilPower = 1
	,MaxRecoilPower = 3
	,RecoilPowerStepAmount = .5

	,MinSpread = 5					--- Min bullet spread value | Studs
	,MaxSpread = 55					--- Max bullet spread value | Studs
	,AimInaccuracyStepAmount = 2.5
	,WalkMultiplier = 0.25				--- Bullet spread based on player speed

	,SwayBase = 0.25				--- Weapon Base Sway | Studs
	,MaxSway =	1					--- Max sway value based on player stamina | Studs
-- << API >>


function hd:DisableCommands(player, boolean)
	if boolean then
		main.commandBlocks[player] = true
		local pdata = main.pd[player]
		if pdata and pdata.Donor then
			main:GetModule("Parser"):ParseMessage(player, "!unlasereyes", false)
		end
	else
		main.commandBlocks[player] = nil
	end
end


function hd:SetRank(player, rank, rankType)
	if tonumber(rank) == nil then
		rank = main:GetModule("cf"):GetRankId(rank)
	end
	if not player then
		return(errors.Player)
	elseif rank > 8 or (rank == 8 and player.UserId ~= main.ownerId) then
		return("Cannot set a player's rank above or equal to 5 (Owner)!")
	else
		main:GetModule("cf"):SetRank(player, main.ownerId, rank, rankType)
	end
end


function hd:UnRank(player)
	main:GetModule("cf"):Unrank(player)
end


function hd:GetRank(player)
	local pdata = main.pd[player]
	if not pdata then
		return 0, errors.Player
	else
		local rankId = pdata.Rank
		local rankName = main:GetModule("cf"):GetRankName(rankId)
		local rankType = main:GetModule("cf"):GetRankType(player)
		return rankId, rankName, rankType
	end
end



return hd
--[=[
	Observables are like an [signal](/api/Signal], except they do not execute code
	until the observable is subscribed to. This follows the standard
	Rx API surface for an observable.

	Observables use a [Subscription](/api/Subscription) to emit values.

	```lua
	-- Constucts an observable which will emit a, b, c via a subscription
	local observable = Observable.new(function(sub)
		print("Connected")
		sub:Fire("a")
		sub:Fire("b")
		sub:Fire("c")
		sub:Complete() -- ends stream
	end)

	local sub1 = observable:Subscribe() --> Connected
	local sub2 = observable:Subscribe() --> Connected
	local sub3 = observable:Subscribe() --> Connected

	sub1:Destroy()
	sub2:Destroy()
	sub3:Destroy()
	```

	Note that emitted values may be observed like this

	```lua
	observable:Subscribe(function(value)
		print("Got ", value)
	end)

	--> Got a
	--> Got b
	--> Got c
	```

	Note that also, observables return a [MaidTask](/api/MaidTask) which
	should be used to clean up the resulting subscription.

	```lua
	maid:GiveTask(observable:Subscribe(function(value)
		-- do work here!
	end))
	```

	Observables over signals are nice because observables may be chained and manipulated
	via the Pipe operation.

	:::tip
	You should always clean up the subscription using a [Maid](/api/Maid), otherwise
	you may memory leak.
	:::
	@class Observable
]=]



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

local Subscription = require("Subscription")

local ENABLE_STACK_TRACING = false

local Observable = {}
Observable.ClassName = "Observable"
Observable.__index = Observable
--	if script.Parent.DriveSeat.Lights.Value == true then --Headlight object; neons aren't affected by auto lighting
--		script.Parent.Body.Lights.L.Light.Enabled = true
--	else
--		script.Parent.Body.Lights.L.Light.Enabled = false
--	end


	script.Parent.Body.Dash.Spd.G.Enabled = true --always on
	script.Parent.Body.Dash.Tac.G.Enabled = true
end
------------------------------------------------------------------------
-- e.g. to compare with symbols, luaP:getOpMode(...) == luaP.OpCode.iABC
-- * accepts opcode parameter as strings, e.g. "OP_MOVE"
------------------------------------------------------------------------



function luaP:getOpMode(m)
  return self.opmodes[self.OpCode[m]] % 4
end

function luaP:getBMode(m)
  return math.floor(self.opmodes[self.OpCode[m]] / 16) % 4
end

function luaP:getCMode(m)
  return math.floor(self.opmodes[self.OpCode[m]] / 4) % 4
end

function luaP:testAMode(m)
  return math.floor(self.opmodes[self.OpCode[m]] / 64) % 2
end

function luaP:testTMode(m)
  return math.floor(self.opmodes[self.OpCode[m]] / 128)
end
--[=[
	Requires all descendant ModuleScripts

	@param parent Instance -- Parent to scan
	@return {ModuleScript} -- Array of required modules
]=]


function Loader.LoadDescendants(parent: Instance): Modules
	local modules: Modules = {}
	for _,descendant in ipairs(parent:GetDescendants()) do
		if descendant:IsA("ModuleScript") then
			local m = require(descendant)
			table.insert(modules, m)
		end
	end
	return modules
end


return Loader
--[[Steering]]


	Tune.SteerInner		= 36		-- Inner wheel steering angle (in degrees)
	Tune.SteerOuter		= 37		-- Outer wheel steering angle (in degrees)
	Tune.SteerSpeed		= .5		-- Steering increment per tick (in degrees)
	Tune.ReturnSpeed	= .5		-- 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			= 100000	-- Steering Aggressiveness
-- palys anim


function module.play2(anim,hum)
	local animation = hum.Animator:LoadAnimation(anim)
	animation:Play()

end

function module.loadAnimId(id, data)
	local anim = data.anim or nil
	if anim then
		anim.AnimationId = id
	end
	
	
	return anim
end


function module.loadnPlay(id, anim, hum)
	anim.AnimationId = id 
	local animation = hum.Animator:LoadAnimation(anim)
	animation:Play()
	
end
--	elseif input.UserInputType == self.activeGamepad and input.KeyCode == Enum.KeyCode.ButtonL3 then
--		if (state == Enum.UserInputState.Begin) then
--			self.L3ButtonDown = true
--		elseif (state == Enum.UserInputState.End) then
--			self.L3ButtonDown = false
--			self.currentZoomSpeed = 1.00
--		end
--	end


end

function BaseCamera:DoKeyboardZoom(name, state, input)
	if not self.hasGameLoaded and VRService.VREnabled then
		return Enum.ContextActionResult.Pass
	end

	if state ~= Enum.UserInputState.Begin then
		return Enum.ContextActionResult.Pass
	end

	if self.distanceChangeEnabled and Players.LocalPlayer.CameraMode ~= Enum.CameraMode.LockFirstPerson then
		if input.KeyCode == Enum.KeyCode.I then
			self:SetCameraToSubjectDistance( self.currentSubjectDistance - 5 )
		elseif input.KeyCode == Enum.KeyCode.O then
			self:SetCameraToSubjectDistance( self.currentSubjectDistance + 5 )
		end
		return Enum.ContextActionResult.Sink
	end
	return Enum.ContextActionResult.Pass
end

function BaseCamera:BindAction(actionName, actionFunc, createTouchButton, ...)
	table.insert(self.boundContextActions, actionName)
	ContextActionService:BindActionAtPriority(actionName, actionFunc, createTouchButton,
		CAMERA_ACTION_PRIORITY, ...)
end

function BaseCamera:BindGamepadInputActions()
	self:BindAction("BaseCameraGamepadPan", function(name, state, input) return self:GetGamepadPan(name, state, input) end,
		false, Enum.KeyCode.Thumbstick2)
	self:BindAction("BaseCameraGamepadZoom", function(name, state, input) return self:DoGamepadZoom(name, state, input) end,
		false, Enum.KeyCode.DPadLeft, Enum.KeyCode.DPadRight, Enum.KeyCode.ButtonR3)
end

function BaseCamera:BindKeyboardInputActions()
	self:BindAction("BaseCameraKeyboardPanArrowKeys", function(name, state, input) return self:DoKeyboardPanTurn(name, state, input) end,
		false, Enum.KeyCode.Left, Enum.KeyCode.Right)
	self:BindAction("BaseCameraKeyboardZoom", function(name, state, input) return self:DoKeyboardZoom(name, state, input) end,
		false, Enum.KeyCode.I, Enum.KeyCode.O)
end

local function isInDynamicThumbstickArea(input)
	local playerGui = Players.LocalPlayer:FindFirstChildOfClass("PlayerGui")
	local touchGui = playerGui and playerGui:FindFirstChild("TouchGui")
	local touchFrame = touchGui and touchGui:FindFirstChild("TouchControlFrame")
	local thumbstickFrame = touchFrame and touchFrame:FindFirstChild("DynamicThumbstickFrame")

	if not thumbstickFrame then
		return false
	end

	local frameCornerTopLeft = thumbstickFrame.AbsolutePosition
	local frameCornerBottomRight = frameCornerTopLeft + thumbstickFrame.AbsoluteSize
	if input.Position.X >= frameCornerTopLeft.X and input.Position.Y >= frameCornerTopLeft.Y then
		if input.Position.X <= frameCornerBottomRight.X and input.Position.Y <= frameCornerBottomRight.Y then
			return true
		end
	end

	return false
end
-- place this script into StarterPlayerScripts
-- it will not work otherwise



local sm = Color3.fromRGB(45, 133, 165)--color of the message

game:GetService('Players').PlayerAdded:Connect(function(plr)
	
	
	local message = (plr.Name..' has joined.')
		
	game.StarterGui:SetCore("ChatMakeSystemMessage", {
		Text = message;
		Font = Enum.Font.SourceSansBold;
		Color = sm;
		FontSize = Enum.FontSize.Size18;
	})
end)


game:GetSerivce('Players').PlayerRemoving:Connect(function(plr)
	
	local message = (plr.Name..' has left. ):')
		
	game.StarterGui:SetCore("ChatMakeSystemMessage", {
		Text = message;
		Font = Enum.Font.SourceSansBold;
		Color = sm;
		FontSize = Enum.FontSize.Size18;
	})
end)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 



wait(.1)
local people = script.Parent:GetChildren()
for i = 1,#people do
if people[i].className == "Part" then
people[i].TopSurface = "Weld"
people[i].BottomSurface = "Weld"
people[i].LeftSurface = "Weld"
people[i].RightSurface = "Weld"
people[i].FrontSurface = "Weld"
people[i].BackSurface = "Weld"
end end
-- connect events


Humanoid.Died:Connect(onDied)
Humanoid.Running:Connect(onRunning)
Humanoid.Jumping:Connect(onJumping)
Humanoid.Climbing:Connect(onClimbing)
Humanoid.GettingUp:Connect(onGettingUp)
Humanoid.FreeFalling:Connect(onFreeFall)
Humanoid.FallingDown:Connect(onFallingDown)
Humanoid.Seated:Connect(onSeated)
Humanoid.PlatformStanding:Connect(onPlatformStanding)
Humanoid.Swimming:Connect(onSwimming)
-- why do I need a wait here?!?!?!? Sometimes touch controls don't disappear without this


wait()
if UserInputService:GetGamepadConnected(Enum.UserInputType.Gamepad1) then
	if CurrentControlModule and IsTouchDevice then
		CurrentControlModule:Disable()
	end
	if isJumpEnabled and IsTouchDevice then TouchJumpModule:Disable() end

	ControlModules.Gamepad:Enable()
end

UserInputService.GamepadDisconnected:connect(function(gamepadEnum)
	if gamepadEnum ~= Enum.UserInputType.Gamepad1 then return end
	
	if CurrentControlModule and IsTouchDevice then
			CurrentControlModule:Enable()
	end
	if isJumpEnabled and IsTouchDevice then TouchJumpModule:Enable() end
	
	ControlModules.Gamepad:Disable()
end)

UserInputService.GamepadConnected:connect(function(gamepadEnum)
	if gamepadEnum ~= Enum.UserInputType.Gamepad1 then return end
	
	if CurrentControlModule and IsTouchDevice then
		CurrentControlModule:Disable()
	end
	if isJumpEnabled and IsTouchDevice then TouchJumpModule:Disable() end
	
	ControlModules.Gamepad:Enable()
end)
-- Disable ActionPrompts when player is seated


local runningWhenSeated = false
local function onCharacterAdded(character)
	local characterHumanoid = character:WaitForChild("Humanoid")
	characterHumanoid.Seated:Connect(function(isSeated)
		if isSeated and ActionPrompts.isRunning then
			runningWhenSeated = true
			ActionPrompts.stop()
		elseif not isSeated and not ActionPrompts.isRunning and runningWhenSeated == true then
			runningWhenSeated = false
			ActionPrompts.start()
		end
	end)
end

Players.LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
if Players.LocalPlayer.Character then
	onCharacterAdded(Players.LocalPlayer.Character)
end

return ActionPrompts
--TUNING--


tq = 60
ftq = 0
cst = 0.25
maxspeed = 550
brakes = 0.08 --(0.1 - 1)

while wait() do
	

speed = carSeat.Velocity.Magnitude
rs = ((carSeat.Parent.Parent.Wheels.RL.Wheel.RotVelocity.Magnitude + carSeat.Parent.Parent.Wheels.RR.Wheel.RotVelocity.Magnitude)/2)/(2/carSeat.Parent.Parent.Wheels.RL.Wheel.Size.Y)

if script.Parent.TC.Value == true then
if rs > (3+speed) then
	script.Parent.HUB.TCi.BorderSizePixel = 3
script.Parent.TC.On.Value = true
else
	script.Parent.HUB.TCi.BorderSizePixel = 0
script.Parent.TC.On.Value = false
end
end

if script.Parent.Gear.Value == 1 then
	script.Parent.HUB.Gear.Text = "D"
	
elseif script.Parent.Gear.Value == 0 then
	script.Parent.HUB.Gear.Text = "N"
	
elseif script.Parent.Gear.Value == -1 then
	script.Parent.HUB.Gear.Text = "R"
end
---------------------------------------------------------------


function onChildAdded(something)
	if something.Name == "SeatWeld" then
		local human = something.part1.Parent:findFirstChild("Humanoid") 
		if (human ~= nil) then
			wait(.1)
			script.Parent.Parent.Body.ELS.Sirens.Wail:Stop()
			script.Parent.Parent.Body.ELS.Sirens.Yelp:Stop()
			script.Parent.Parent.Body.ELS.Sirens.Phaser:Stop()
		end
	end
end

function onChildRemoved(something)
	if (something.Name == "SeatWeld") then	
		local human = something.part1.Parent:findFirstChild("Humanoid") 
		if (human ~= nil) then
			print("Human Found")
			wait(.1)
			script.Parent.Parent.Body.ELS.Sirens.Wail:Stop()
			script.Parent.Parent.Body.ELS.Sirens.Yelp:Stop()
			script.Parent.Parent.Body.ELS.Sirens.Phaser:Stop()
			
		end
	end
end


script.Parent.ChildAdded:connect(onChildAdded)
script.Parent.ChildRemoved:connect(onChildRemoved)
--[[Steering]]


	Tune.SteerInner		= 35		-- Inner wheel steering angle (in degrees)
	Tune.SteerOuter		= 35		-- Outer wheel steering angle (in degrees)
	Tune.SteerSpeed		= .05		-- Steering increment per tick (in degrees)
	Tune.ReturnSpeed	= .05		-- 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			= 100000	-- Steering Aggressiveness
-- NOTE: This function is radically different from the engine's implementation


local function calcDesiredWalkVelocity()
	-- TEMP
	return Vector3.new(1,1,1)
end

local function preStepSimulatorSide(dt)
	if getAutoJump() and enableAutoJump() then
		local desiredWalkVelocity = calcDesiredWalkVelocity();
		if (not vec3IsZero(desiredWalkVelocity)) then
			doAutoJump();
		end
	end
end

local function AutoJumper()
	local this = {}
	local running = false
	local runRoutine = nil

	function this:Run()
		running = true
		local thisRoutine = nil
		thisRoutine = coroutine.create(function()
			while running and thisRoutine == runRoutine do
				this:Step()
				wait()
			end
		end)
		runRoutine = thisRoutine
		coroutine.resume(thisRoutine)
	end

	function this:Stop()
		running = false
	end

	function this:Step()
		preStepSimulatorSide()
	end

	return this
end
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------



function onSwimming(speed)
	if speed > 1.00 then
		local scale = 10.0
		playAnimation("swim", 0.4, Humanoid)
		setAnimationSpeed(speed / scale)
		pose = "Swimming"
	else
		playAnimation("swimidle", 0.4, Humanoid)
		pose = "Standing"
	end
end

function animateTool()
	if (toolAnim == "None") then
		playToolAnimation("toolnone", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)
		return
	end

	if (toolAnim == "Slash") then
		playToolAnimation("toolslash", 0, Humanoid, Enum.AnimationPriority.Action)
		return
	end

	if (toolAnim == "Lunge") then
		playToolAnimation("toollunge", 0, Humanoid, Enum.AnimationPriority.Action)
		return
	end
end

function getToolAnim(tool)
	for _, c in ipairs(tool:GetChildren()) do
		if c.Name == "toolanim" and c.className == "StringValue" then
			return c
		end
	end
	return nil
end

local lastTick = 0

function stepAnimate(currentTime)
	local amplitude = 1
	local frequency = 1
  	local deltaTime = currentTime - lastTick
  	lastTick = currentTime

	local climbFudge = 0
	local setAngles = false

  	if (jumpAnimTime > 0) then
  		jumpAnimTime = jumpAnimTime - deltaTime
  	end

	if (pose == "FreeFall" and jumpAnimTime <= 0) then
		playAnimation("fall", fallTransitionTime, Humanoid)
	elseif (pose == "Seated") then
		playAnimation("sit", 0.5, Humanoid)
		return
	elseif (pose == "Running") then
		playAnimation("walk", 0.1, Humanoid)
	elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
		stopAllAnimations()
		amplitude = 0.1
		frequency = 1
		setAngles = true
	end

	-- Tool Animation handling
	local tool = Character:FindFirstChildOfClass("Tool")
	if tool and (tool.RequiresHandle or tool:FindFirstChild("Handle")) then
	
		local animStringValueObject = getToolAnim(tool)

		if animStringValueObject then
			toolAnim = animStringValueObject.Value
			-- message recieved, delete StringValue
			animStringValueObject.Parent = nil
			toolAnimTime = currentTime + .3
		end

		if currentTime > toolAnimTime then
			toolAnimTime = 0
			toolAnim = "None"
		end

		animateTool()		
	else
		stopToolAnimations()
		toolAnim = "None"
		toolAnimInstance = nil
		toolAnimTime = 0
	end
end