So I did some tutorials here and there, and I'm trying to make the part blow up up every 55 seconds if it is touching the current part. But it won't even say that it's touching the model when I put it right on it.
local RESET_SECONDS = 1 local isTouched = false if not isTouched then isTouched = true script.Parent.Touched:Connect(function(obj) if obj:IsDescendantOf(game.workspace.car) then local explosion = Instance.new("Explosion") explosion.BlastRadius = 1000000 explosion.Parent = game.Workspace explosion.Position = script.Parent.Position print('model touched') else print("couldn't find model") end wait(55) end) wait(RESET_SECONDS) -- Wait for reset time duration isTouched = false -- Reset variable to false end
Your doing it wrong, you should be checking the isTouched inside of the Touched event:
local RESET_SECONDS = 1 local isTouched = false script.Parent.Touched:Connect(function() if not isTouched then isTouched = true -- Code for the explosion thing task.wait(resetSeconds) isTouched = false end end
Also can you give me the link for the tutorial because I think the person made the tutorial is cool