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

How do I fix my script to make the player get slower upon falling from a certain height?

Asked by 4 years ago
Edited 4 years ago

So I took a script from somewhere else and tried to repurpose it to make it to make the player slower after a fall instead of taking damage. There are 2 pieces to this code. (2 parts of a script) The parent script is AddFallSlow, and the child script is FallSlow. My problem is that it does not work, nothing happens when I test it.

Here is the parent script, AddFallSlow

function fallSlow(entrant)
    if game.Players:findFirstChild(entrant.Name) then --Finds whether or not the added child is a player
        wait(2) --Makes sure the player doesn't take damage just from spawning in
        fallDmg = script.FallDamage:clone()
        fallDmg.Disabled = false
        fallDmg.Parent = entrant
    end
end

game.Workspace.ChildAdded:connect(fallSlow)

Here is the child script, FallSlow

fallTime = 0
while true do
    x = wait()
    if script.Parent.Torso.Velocity.Y <= -10 then --Finds whether or not the player has begun falling and starts a timer
        fallTime = fallTime + x
    end
    if script.Parent.Torso.Velocity.Y > -10 then --Finds when the player has stopped falling
        if fallTime >= 0.4 then --Finds whether or not the player has been falling long enough to take damage
            script.Parent.Humanoid.Walkspeed = ( 16 / 2 )
        end
        fallTime = 0
    end
end

Help would be appreciated, thank you in advance.

Answer this question