Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesnt there come any explosion after touch?

script.Parent.Touched:Connect(function(hit)
	    if hit ~= game.Workspace.Spawner then   -- the ~= means "Does not equal"
			        local EX = Instance.new("Explosion")
		       EX.DestroyJointRadiusPercent = 0
			        EX.Position = script.Parent.Position
			        EX.BlastPressure = 10
			        EX.BlastRadius = 40
		EX.Hit:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") ~= nil then
				hit.Parent:FindFirstChild("Humanoid"):TakeDamage(2)
			        EX.Parent = script.Parent
			end
			end)

i def did something wrong but it doesnt show errors

1 answer

You have the script set the explosion to workspace when the explosion is hit. Explosions only explode when they are a descendant of workspace. You’d have to set it’s parent before the event.


EX.Position = script.Parent.Position
EX.BlastPressure = 10
EX.BlastRadius = 40
EX.Parent = script.Parent

EX.Hit:Connect(function(hit)
   if hit.Parent:FindFirstChild("Humanoid") ~= nil then
       hit.Parent:FindFirstChild("Humanoid"):TakeDamage(2)	                   	  
   end
end)

1 comment

0

yeah but how do i make it explode unless a part name is spawner

This discussion is preserved as it was. New answers, comments, and votes are closed.