Hi, I am making a treadmill for my weight lifting simulator, but the loop never stops when I step off the treadmill. I've tried to make a true or false statement but it did not work. Anybody have a possible solution?
local character = game.Players.LocalPlayer.Character.Humanoid
local speed = game.ReplicatedStorage.Speed
function onTouched(hit)
while true do
speed.Value = speed.Value + 10
wait(1)
speed.Value = speed.Value + 10
wait(1)
end
end
script.Parent.Touched:connect(onTouched)
if character = nil then
return
end

2 comments
I am pretty sure there is an event called TouchEnded. Try putting that into use!
Maybe try using "Until"?