Putting click detector in part that is a child of player

  1. Trying to put a click detector in a part that is in a player.

  2. The click detector will not destroy the part when clicked, this is inside of a player so could that cause it?

	print("yes")
	script.Parent:Destroy()
end)
2 Likes

is this yes printings also could you show more of the code

1 Like

Also, is this a localscript? how are you checking if its destroyed? It may be destroyed on the client but not on the server. (or reversed)

1 Like

Provided you have the ClickDetector object inside the Part, can you try this?

--This should be inside the Part
local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")
local PartToFind = "PartNameHere"

local function Clicked(Player)
    local Char = Player.Character

    if Char and Char:FindFirstChild(PartToFind) then
        Char[PartToFind]:Destroy()
    end
end

ClickDetector.MouseClick:Connect(Clicked)

It would help us if you could provide more details on what’s currently happening when you click it :slightly_smiling_face: