Hello!
I’m currently scripting a system that allows users to skate for a group my friend is making. I was wondering why you can only go a certain speed.
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
Player.CharacterAdded:wait()
Character = Player.Character
Torso = Character:WaitForChild("Torso")
LL = Character:WaitForChild("Left Leg")
RL = Character:WaitForChild("Right Leg")
Humanoid = Character:WaitForChild("Humanoid")
Tool = script.Parent
Anim = Tool:WaitForChild("Anim")
Anim.Parent = Character
wait()
AnimTrack = Humanoid:LoadAnimation(Anim)
Anim.Parent = Tool
Activated = nil
BodyForce = nil
Velocity = 0
Force = 950
function Weld(Part, C0)
end
Tool.Selected:connect(function()
BodyForce = Instance.new("BodyForce", Torso)
Activated = true
end)
Tool.Deselected:connect(function()
Activated = nil
AnimTrack:Stop()
BodyForce:remove()
print("Removed")
end)
Torso.Parent.Humanoid.Running:connect(function(SpeedyGnome)
while SpeedyGnome > 1.3 do
wait()
if Activated then
local Ray = Ray.new(Torso.Position, Vector3.new(0, -5, 0))
local Hit = game.Workspace:FindPartOnRay(Ray, Character)
if Hit == nil or Hit.Material ~= Enum.Material.Ice then
BodyForce.Force = Vector3.new(0, 0, 0)
if AnimTrack.IsPlaying then
AnimTrack:Stop()
end
else
BodyForce.Force = Torso.CFrame.lookVector * Torso:GetMass() * Force
if AnimTrack.IsPlaying == false then
AnimTrack:Play(0, 1, 3 - Torso.Velocity.magnitude * 0.04)
end
end
elseif Activated == false then
BodyForce.Force = BodyForce.Force * 0.99
end
end
end)
Here is a gif of it in action (you’ll notice how you can only go a certain speed)
https://gyazo.com/c9cd016f1b843c1552edc46d604e19ac.gf