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

Remove when Pike Pole touches glass?

I'm trying to make a script where if the Pike Pole touches the part it removes.

But I have multiple of them in the game. So I don't want all the parts named "Glass" to remove

local part = script.Parent
part.Touched:connect(function(hit)
	if hit.Parent then
		local pike = hit.Parent:FindFirstChild("Pike Pole")
		if pike then
			script.Parent.Glass:remove()
		end
	end
end)


it worked when I did game.Workspace.Glass:remove()

though

2 comments

0

Is this script in the glass?

0

yes

1 answer

You are trying to find a object named glass inside of the glass part, so it'll never work.

local part = script.Parent -- The glass
part.Touched:connect(function(hit)
    if hit.Parent then
        local pike = hit.Parent:FindFirstChild("Pike Pole")
        if pike then
            part:Destroy() -- Kill glass
        end
    end
end)

2 comments

0

That worked! Thank you.

0

No problem.

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