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

ontouch or touch invalid?

local brick = game.Workspace      --the part that u wnt to have explode when touched

brick.Touched:connect(function(hit)
    if hit.Parent and hit.Parent.Humanoid then
        humanoid = hit.Parent.Humanoid
        explode = Instance.new("Explosion", brick)
end)

1 answer

✓ Accepted answer
function ont (hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid") 
	if humanoid then
		local e = Instance.new("Explosion")
		e.Parent = script.Parent
		e.Position = script.Parent.Position
	end
end

script.Parent.Touched:connect(ont)

There you go, that should work!

3 comments

0

Reason for error: Your local brick is the whole workspace, if you wanted to do the whole workspace then you would need to do game.Workspace:GetChildren() <-- using that to replace the bricj - game.Workspace you also need a position for the explosion.

0

Thanks!!

0

You should also keep the hit.Parent check!

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