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

Why does this script not print something when an car goes at 40 speed?

The script is supposed to print something if a car is going at 40 speed. Heres the script:

while wait() do
	local speed = script.Parent.Velocity.Magnitude
	if speed == 40 then
		print("you are going too fast")
	end
	wait()
end

3 comments

0

Loops won't work at all. And if speed == 40 causes the error. try <= instead?

0

That sadly didnt work.

0

just because loops won't work.

1 answer

✓ Accepted answer

Instead of speed == 40 do speed >= 40 because the way you increase speed may make the speed go over 40, while skipping it. (like if you increase the speed by +3 or any number thats not a divisor of 40, the speed will never equal 40).

5 comments

0

Thanks you so much, it worked!

0

does it work without while wait() do?

0

you can make it so that it checks every time the speed changes with the :Changed event

0

on what variable do i need to do that?

0

on the magnitude, of course

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