How would I check if a player is inside a vehicle and delete it after a set amount of time?

Hey all.

So I am somewhat new to scripting, and I have never wrote a script like this before, anyways no more excuses.

I think you should use a for loop, but I don’t really know how to use them
should you use for i = 1, 30 (delete after 30 seconds after a player hasn’t touched it) type of loop?
Heres the script if you need it:

function onTouch(part) 
	local humanoid = part.Parent:FindFirstChild("Humanoid") 
	if (humanoid ~= nil) then	
		script.ifin.Value = true
	end 
end

script.Parent.Touched:connect(onTouch)

You can do this

local Cooldown = 30
local debounce = true

while debounce do
wait(1) ← Not putting a wait can crash or break your script, it sends too many requests
Cooldown -= 1
if Cooldown == 0 then
debounce = false
Do your script here for whatever you wish to do
end
end

This is just a simple countdown script, make it into your own since the rest should be easy and basic, if you need any other help feel free to reply.

2 Likes