Hello everyone, I was creating a little script where if someone touches the seat again, then the loop stops. So I added a little if statement that goes like this.
local seat = script.Parent
seat.TouchEnded:Connect(function())
local count = 0
while count < 30 do
if seat.Touched then
break
end
if count == 30 then
game.Workspace.Tank:Destroy()
end
count = count + 1
wait(0.5)
end
end)
So I think I have done a little weird mistake, like i'm doubting the line that says "if seat.Touched then". Please help me with my script. Thanks!

1 comment
Did you test it out? What the code should do, is that if the player sat on the seat, and then got of it, and doesn't get back on in 30 seconds, then the tank should get despawned. But if the player touches the seat just in time, then it should break from the loop, and prevent the tank from getting despawned.