Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

WalkSpeed Script not working?

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

✓ Accepted answer

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.

3 comments

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.

1

I got it to work now. Idk what I did wrong before, but it works now. Tyvm. :)

0

No probs!

This discussion is preserved as it was. New answers, comments, and votes are closed.