How do I make this special wait script? I'm trying to make it so that if the vehicle seat this script is in does not move faster than 10 magnitude for more than 20 seconds, its joints break.
But I think I have made a script that if the speed is less than 10 magnitude for even a second, it will wait 20 seconds an still carry out the activity, which is not what I want.
I know this is no where near right, but I do not know what I am doing.
if script.Parent.Velocity.Magnitude < 10 then wait(20) script.Parent:BreakJoints() end
while true do wait() if script.Parent.Velocity.Magnitude < 10 then -- The "then" needs to be on the same line as "if." for i=0, 21, 1 do magnitude = script.Parent.Velocity.Magnitude wait(1) i = i+1 if magnitude < 10 and i >= 20 then script.Parent:BreakJoints() elseif magnitude >= 10 or i >= 20 then break end end end end
Try this.
I don't have a whole lot of time on my hands today, so I can't properly explain it all right now, write a comment if anything doesn't make sense/it doesn't work. Sorry about that.
local startTime = tick(); -- make timer while wait(1) do if(script.Parent.Velocity.Magnitude >= 10) then startTime = tick(); -- reset timer when moving faster than 10 studs/second elseif(tick()-startTime >= 20) then script.Parent:BreakJoints(); end end