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 4 years ago
Edited 4 years ago

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

heres what i got

1                    local Walkspeed = Target.Humanoid.WalkSpeed
2    Target.Humanoid:TakeDamage(_Damage.Value)
3    Target.Humanoid.WalkSpeed  = 0
4wait(_icetime)
5    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 4 years ago
Edited 4 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.

01local Players = game:GetService("Players")
02 
03for i,v in pairs(Players:GetPlayers()) do -- for loop
04    local char = v.Character or v.CharacterAdded:Wait()
05    local hum = char:WaitForChild("Humanoid")
06    local oldWalkSpeed = hum.WalkSpeed -- Old WalkSpeed variable, i.e. 16
07    print(oldWalkSpeed)
08 
09    if hum then
10        hum.WalkSpeed = 0  -- WalkSpeed to 0
11        wait(_icetime)
12        hum.WalkSpeed = oldWalkSpeed -- WalkSpeed to 16
13        print(hum.WalkSpeed)
14    end
15end
Ad

Answer this question