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

WalkSpeed Script not working?

Asked by 8 years ago

Alright, so all I am trying to do is make a person's WalkSpeed 0 when they click on an ImageButton. The rest of the script is to make their WalkSpeed 16 again once my "countdown" reaches 0. If I need to explain anything with my "countdown" then I can, though I do not think the problem lies with the countdown. When I run the script, the output tells me, 11:11:21.331 - Players.Player.PlayerGui.PumpkinCarver.MainFrame.PC - Pumpkin Carver.OnClick:3: '=' expected near '­'

function onClick()

    script.Parent.Parent.Parent.Parent.Chara­cter.Humanoid.WalkSpeed = 0

    local NumberValue = script.Parent.Parent.Parent.ImageLabel.TimeLeft.Value
    if NumberValue.Value == 0 then
script.Parent.Parent.Parent.Parent.Chara­cter.Humanoid.WalkSpeed = 16
    end
end

script.Parent.MouseButton1Click:connect(onClick)

Any thoughts? Thank you. :)

1 answer

Log in to vote
0
Answered by
yumtaste 476 Moderation Voter
8 years ago

Line 6 only checks to see if the NumberValue.value is 0 once. You'd need a loop there.

while numberValue.Value ~= 0 do
wait()
end
--set walkspeed

For every about half second that the value is not 0, the loop will check again. Also, make sure all of your variables are right.

0
Hmm. Perhaps I implemented the code wrong. It does make the WalkSpeed 0 when the Value is not equal to 0, but when the Value equals zero, nothing happens. Malefactus 55 — 8y
1
I got it to work now. Idk what I did wrong before, but it works now. Tyvm. :) Malefactus 55 — 8y
0
No probs! yumtaste 476 — 8y
Ad

Answer this question