function makeGyro(S)Gyro=Instance.new("\066\111\100\121\071\121\114\111")Gyro.Name="\083\107\097\116\101\098\111\097\114\100\071\121\114\111"Gyro.maxTorque=Vector3.new(0,0,0)Gyro.P=50 Gyro.D=50 Gyro.Parent=S.Parent.Torso end function onButtonChanged(S)if S==Enum.Button.Dismount then Board.ControllingHumanoid.Jump=Controller:getButton(Enum.Button.Dismount)end if S==Enum.Button.Jump then if Controller:getButton(Enum.Button.Jump)and jumpok then jumpok=false KickAnim:Stop()LeftAnim:Stop(.5)RightAnim:Stop(.5)OllieAnim:Play(0,1,4)Board.StickyWheels=false Board:ApplySpecificImpulse(Vector3.new(0,45,0))OllieHack.force=Vector3.new(0,1200,0)didAction("\106\117\109\112")delay(.1,function()if OllieHack~=nil then OllieHack.force=Vector3.new(0,0,0)end end)else Board.StickyWheels=true end end end function onEquip(S,w)print("\066\111\097\114\100 \101\113\117\105\112\112\101\100")print(w)if not Controller then Controller=w makeGyro(S)w.AxisChanged:connect(onAxisChanged)Board.MoveStateChanged:connect(onMoveStateChanged)CoastingAnim=S:loadAnimation(Board.coastingpose)LeftAnim=S:loadAnimation(Board.leftturn)RightAnim=S:loadAnimation(Board.rightturn)OllieAnim=S:loadAnimation(Board.ollie)KickAnim=S:loadAnimation(Board.boardkick)CoastingAnim:Play()Controller:bindButton(Enum.Button.Jump,"\079\108\108\105\101")Controller:bindButton(Enum.Button.Dismount,"\068\105\115\109\111\117\110\116")Controller.ButtonChanged:connect(onButtonChanged)end end function onUnequip(S)print("\066\111\097\114\100 \117\110\101\113\117\105\112\112\101\100")Controller=nil Gyro.Parent=nil Gyro=nil CoastingAnim:Stop()KickAnim:Stop()CoastingAnim=nil KickAnim=nil LeftAnim:Stop()LeftAnim=nil RightAnim:Stop()RightAnim=nil OllieAnim:Stop()OllieAnim=nil if OllieThrust~=nil then OllieThrust:Remove()OllieThrust=nil end end
-- initialization/finalization stuff

function makeGyro(humanoid)
	Gyro = Instance.new("BodyGyro")
	Gyro.Name = "SkateboardGyro"
	Gyro.maxTorque = Vector3.new(0, 0, 0) -- start off
	Gyro.P = 50
	Gyro.D = 50
	Gyro.Parent = humanoid.Parent.Torso
end

function onButtonChanged(button)
	if button == Enum.Button.Dismount then
		Board.ControllingHumanoid.Jump = Controller:getButton(Enum.Button.Dismount)
	end
	if button == Enum.Button.Jump then
		if Controller:getButton(Enum.Button.Jump) and jumpok then
			jumpok = false
			KickAnim:Stop()
			LeftAnim:Stop(0.5)

			RightAnim:Stop(0.5)
			OllieAnim:Play(0, 1, 4)
			Board.StickyWheels = false
			Board:ApplySpecificImpulse(Vector3.new(0, 45, 0))
			OllieHack.force = Vector3.new(0, 1200, 0)
			didAction("jump")
			delay(0.1, function()
				if OllieHack ~= nil then
					OllieHack.force = Vector3.new(0, 0, 0)
				end
			end)
		else
			Board.StickyWheels = true
		end
	end
end

function onEquip(humanoid, controller)
	print("Board equipped")
	print(controller)
	if not Controller then -- debounce
		Controller = controller

		makeGyro(humanoid)
		controller.AxisChanged:connect(onAxisChanged)
		Board.MoveStateChanged:connect(onMoveStateChanged)
		CoastingAnim = humanoid:loadAnimation(Board.coastingpose)
		LeftAnim = humanoid:loadAnimation(Board.leftturn)
		RightAnim = humanoid:loadAnimation(Board.rightturn)
		OllieAnim = humanoid:loadAnimation(Board.ollie)
		--OllieAnim:AdjustSpeed(2)
		KickAnim = humanoid:loadAnimation(Board.boardkick)
		CoastingAnim:Play()

		Controller:bindButton(Enum.Button.Jump, "Ollie")
		Controller:bindButton(Enum.Button.Dismount, "Dismount")
		Controller.ButtonChanged:connect(onButtonChanged)
	end
end

function onUnequip(board)
	print("Board unequipped")
	Controller = nil
	Gyro.Parent = nil
	Gyro = nil
	CoastingAnim:Stop()
	KickAnim:Stop()
	CoastingAnim = nil
	KickAnim = nil
	LeftAnim:Stop()
	LeftAnim = nil
	RightAnim:Stop()
	RightAnim = nil
	OllieAnim:Stop()
	OllieAnim = nil

	if OllieThrust ~= nil then
		OllieThrust:Remove()
		OllieThrust = nil
	end
end
