I'm attempting to make Proximity mines and I'm unsure if I'm correct on the coding of it. I just needed it to be that if someone is within 3 studs the mine goes off.
If you are trying to make a simple Land Mine type object, we can do this!
local debounce = true -- Just to use as a cooldown local Respawn = 10 --How long it takes for the LandMine to come back script.Parent.Touched:connect(function(plr) if plr.Parent:FindFirstChild('Humanoid') ~= nil then --Making sure it was a player that touched the Mine if debounce == true then --Making sure this doesn't fire before our cooldown is finished debounce = false x = Instance.new('Explosion', workspace) --Inserting the explosion x.Position = script.Parent.Position --Making the explosion happen exactly where our LandMine is script.Parent.Transparency = 1 --Pure aesthetic script.Parent.CanCollide = false --For aesthetic... wait(Respawn) --Waiting our 10 seconds, change local Respawn however long you want it to be script.Parent.Transparency = 0 script.Parent.CanCollide = true debounce = true --Cooldown is over end end end)
Just put this code inside of a regular script, and put that script inside of any part and KABOOM!
Hoped this help. If so, please accept my answer!
If you have any questions about the code or more questions in general, just ask!