I made a script where the part explodes when it collides with anything. How do I make so it only explodes when touching the objects, not with players?
Here's my script;
function onTouched(hit) local e = Instance.new("Explosion") e.BlastRadius = 15 e.BlastPressure = 1000 e.Parent = game.Workspace e.Position = script.Parent.Position end script.Parent.Touched:connect(onTouched)
Add a check for humanoids. Also, add a debounce to not lag the player's game.
local debounce = true function onTouched(hit) if hit.Parent:FindFirstChild("Humanoid") then print('Humanoid found.') else if debounce == true then debounce = false local e = Instance.new("Explosion") e.BlastRadius = 15 e.BlastPressure = 1000 e.Parent = game.Workspace e.Position = script.Parent.Position wait(1) debounce = true else print('deb is false lolololol') end end end script.Parent.Touched:connect(onTouched)