Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make the character run at a fast speed and not slide everywhere?

Asked by 9 years ago

Basically, my script that I currently have involves the character receiving a gui, which allows them to change their walkspeeds. When they go over the speed of 50, a trail will follow behind them. Here is the script for the trail so far, because you guys seem to need "evidence".

local sp = script.Parent.Parent.Character:FindFirstChild("Humanoid")
activate = 50
deactivate = 49

function trail()
    wait(0.01)
    local ft = Instance.new("Part")
    ft.TopSurface = "Smooth"
    ft.BottomSurface = "Smooth"
    ft.Anchored = true
    ft.FormFactor = "Custom"
    ft.Size = Vector3.new(1.98, 1.98, 0.98)
    ft.Transparency = 0.7
    ft.Parent = game.workspace
    ft.CanCollide = false
    ft.BrickColor = BrickColor.new("Bright yellow")
    ft.CFrame = script.Parent.Parent.Character:FindFirstChild("Torso").CFrame
    local light = Instance.new("PointLight")
    light.Range = 10
    light.Brightness = 1
    light.Enabled = true
    light.Shadows = true
    light.Parent = ft
    light.Color = Color3.new(255, 255, 0)
    game.Debris:AddItem(ft,0.8)
    local fla = Instance.new("Part")
    fla.TopSurface = "Smooth"
    fla.BottomSurface = "Smooth"
    fla.Anchored = true
    fla.FormFactor = "Custom"
    fla.Size = Vector3.new(0.98, 1.98, 0.98)
    fla.Transparency = 0.7
    fla.Parent = game.workspace
    fla.CanCollide = false
    fla.BrickColor = BrickColor.new("Bright yellow")
    fla.CFrame = script.Parent.Parent.Character:FindFirstChild("Left Arm").CFrame
    game.Debris:AddItem(fla,0.8)
    local fra = Instance.new("Part")
    fra.TopSurface = "Smooth"
    fra.BottomSurface = "Smooth"
    fra.Anchored = true
    fra.FormFactor = "Custom"
    fra.Size = Vector3.new(0.98, 1.98, 0.98)
    fra.Transparency = 0.7
    fra.Parent = game.workspace
    fra.CanCollide = false
    fra.BrickColor = BrickColor.new("Bright yellow")
    fra.CFrame = script.Parent.Parent.Character:FindFirstChild("Right Arm").CFrame
    game.Debris:AddItem(fra,0.8)
    local fll = Instance.new("Part")
    fll.TopSurface = "Smooth"
    fll.BottomSurface = "Smooth"
    fll.Anchored = true
    fll.FormFactor = "Custom"
    fll.Size = Vector3.new(0.98, 1.98, 0.98)
    fll.Transparency = 0.7
    fll.Parent = game.workspace
    fll.CanCollide = false
    fll.BrickColor = BrickColor.new("Bright yellow")
    fll.CFrame = script.Parent.Parent.Character:FindFirstChild("Left Leg").CFrame
    game.Debris:AddItem(fll,0.8)
    local frl = Instance.new("Part")
    frl.TopSurface = "Smooth"
    frl.BottomSurface = "Smooth"
    frl.Anchored = true
    frl.FormFactor = "Custom"
    frl.Size = Vector3.new(0.98, 1.98, 0.98)
    frl.Transparency = 0.7
    frl.Parent = game.workspace
    frl.CanCollide = false
    frl.BrickColor = BrickColor.new("Bright yellow")
    frl.CFrame = script.Parent.Parent.Character:FindFirstChild("Right Leg").CFrame
    game.Debris:AddItem(frl,0.8)
    local fh = Instance.new("Part")
    fh.TopSurface = "Smooth"
    fh.BottomSurface = "Smooth"
    fh.Anchored = true
    fh.FormFactor = "Custom"
    fh.Size = Vector3.new(0.98, 0.98, 0.98)
    fh.Transparency = 0.7
    fh.Parent = game.workspace
    fh.CanCollide = false
    fh.BrickColor = BrickColor.new("Bright yellow")
    fh.CFrame = script.Parent.Parent.Character:FindFirstChild("Head").CFrame
    game.Debris:AddItem(fh,0.8)
end

while wait() do
    if sp.WalkSpeed >= activate then
        trail()
    end
end
1
We don't need "evidence". don't blame your inability to recognize common sense - that we need CODE to help you fix your CODE - on us. Also, this is pretty much a request which isn't suitable for our question format. Goulstem 8144 — 9y
0
Someone's a bit angry that I didn't make their answer the top answer... But anyways, how is this not suitable? jamesbiggsbot 0 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

The only way I can think of, is by applying a BodyForce in the opposite direction to which the player is moving.

local vel = (OldPosition - NewPosition).magnitude
local unit = (OldPosition - NewPosition).unit
BodyForce.force = -unit * vel
wait()
BodyForce.force = Vector3.new(0, 0, 0)
0
You can make a player aquathorn321 858 — 9y
Ad

Answer this question