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

how do i make the walk speed of a group of things with dif walk speeds back to the same?

Asked by 3 years ago
Edited 3 years ago

how do i make my group of things back to there normal walkspeed after changing it

heres what i got

                                    local Walkspeed = Target.Humanoid.WalkSpeed
                    Target.Humanoid:TakeDamage(_Damage.Value)
                    Target.Humanoid.WalkSpeed  = 0
                wait(_icetime)
                    Target.Humanoid.WalkSpeed =  Walkspeed

they all have a dif walk speed i want them after they get iced to go back to original walkspeed

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I'm not sure what you mean by "they"?

I would use a for loop, and store their previous WalkSpeedin a variable to refer back to after the wait(). I also can't use your variables so you'll have to modify my code to fit your needs.

local Players = game:GetService("Players")

for i,v in pairs(Players:GetPlayers()) do -- for loop
    local char = v.Character or v.CharacterAdded:Wait() 
    local hum = char:WaitForChild("Humanoid")
    local oldWalkSpeed = hum.WalkSpeed -- Old WalkSpeed variable, i.e. 16
    print(oldWalkSpeed)

    if hum then
        hum.WalkSpeed = 0  -- WalkSpeed to 0
        wait(_icetime)
        hum.WalkSpeed = oldWalkSpeed -- WalkSpeed to 16
        print(hum.WalkSpeed)
    end
end
Ad

Answer this question