local U=script.Parent local N local u local M local G local t local L local z local y=script.Parent:FindFirstChild("\079\108\108\105\101\084\104\114\117\115\116")if y==nil then y=Instance.new("\066\111\100\121\084\104\114\117\115\116")y.Name="\079\108\108\105\101\084\104\114\117\115\116"y.force=Vector3.new(0,0,0)y.location=Vector3.new(0,0,-2)y.Parent=U end local E=nil local b=nil local m=true function didAction(U)E=U b=time()end function onAxisChanged(u)U.Steer=N.Steer U.Throttle=N.Throttle if U.Steer==-1 then print("\076\101\102\116")G:Stop()z:Stop()L:Stop(.5)t:Play(.5)didAction("\108\101\102\116")end if U.Steer==1 then print("\082\105\103\104\116")G:Stop()t:Stop(.5)z:Stop()L:Play(.5)didAction("\114\105\103\104\116")end if U.Steer==0 then print("\083\116\114\097\105\103\104\116")G:Stop()t:Stop(.5)z:Stop()L:Stop(.5)if E=="\103\111"and time()-b<.1 then end didAction("\103\111")end end function enterAirState()u.maxTorque=Vector3.new(100,0,100)m=false end function exitAirState()u.maxTorque=Vector3.new(0,0,0)m=true end function enterPushingState()G:Play()end function onMoveStateChanged(U,N)print(N)print(U)if N==Enum.MoveState.AirFree then exitAirState()end if U==Enum.MoveState.AirFree then enterAirState()end if U==Enum.MoveState.Pushing then enterPushingState()end end


local Board = script.Parent
local Controller
local Gyro
local CoastingAnim
local KickAnim
local LeftAnim
local RightAnim
local OllieAnim

local OllieHack = script.Parent:FindFirstChild("OllieThrust")
if (OllieHack == nil) then
	OllieHack = Instance.new("BodyThrust")
	OllieHack.Name = "OllieThrust"
	OllieHack.force = Vector3.new(0,0,0)
	OllieHack.location = Vector3.new(0,0,-2)
	OllieHack.Parent = Board
end

local lastaction = nil
local lasttime = nil
local jumpok = true

function didAction(action)
	lastaction = action
	lasttime = time()
end



function onAxisChanged(axis)
	Board.Steer = Controller.Steer
	Board.Throttle = Controller.Throttle

	if (Board.Steer == -1) then
		print("Left")
		--CoastingAnim:Stop(1)
		KickAnim:Stop()
		OllieAnim:Stop()
		RightAnim:Stop(.5)
		LeftAnim:Play(.5)
		didAction("left")
	end

	if (Board.Steer == 1) then
		print("Right")
		KickAnim:Stop()
		--CoastingAnim:Stop(1)
		LeftAnim:Stop(.5)
		OllieAnim:Stop()
		RightAnim:Play(.5)
		didAction("right")
	end

	if (Board.Steer == 0) then
		print("Straight")

		KickAnim:Stop()
		LeftAnim:Stop(.5)
		OllieAnim:Stop()
		RightAnim:Stop(.5)
		
		if (lastaction == "go" and time() - lasttime < .1) then
			
		end
		didAction("go")
		--CoastingAnim:Play(1)

		
	end
end

function enterAirState()
	-- gyrate towards vertical position for better landing
	Gyro.maxTorque = Vector3.new(100, 0, 100)
	jumpok = false
end

function exitAirState()
	-- turn off gyro
	Gyro.maxTorque = Vector3.new(0,0,0)
	jumpok = true
end

function enterPushingState()
	KickAnim:Play()
end

function onMoveStateChanged(newState, oldState)
	print(oldState)
	print(newState)
	-- do state exits here
	if oldState == Enum.MoveState.AirFree then exitAirState() end

	-- do state transitions here

	-- do state entries here
	if newState == Enum.MoveState.AirFree then enterAirState() end
	if newState == Enum.MoveState.Pushing then enterPushingState() end
end

