Need help with ClickDetector

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I need a script that makes the part destroy after click

  1. What is the issue? Include screenshots / videos if possible!

i can’t find any tutorial’s to do it

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have searched the dev forum and google and tried making my own script also did not work

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

This is my script i tried

-- local script.parent = 'PartToDestroy'
local script.parent.ClickDetector = 'ClickDetect'

game.Workspace.PartToDestroy.MouseClick:Connect(function()
PartToDestroy:Destroy
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

2 Likes
local PartToDestroy = workspace.PartToDestroy
local ClickDetector = PartToDestroy.ClickDetector

ClickDetector.MouseClick:Connect(function()
PartToDestroy:Destroy()
end)

make sure to add cclickerdector in parttodestroy

(paste code)

It works :tada: thank you. i hope you have a great day

2 Likes

Wait so i tried it again and it dosen’t work if the part is in a model. sorry to bug you if you are busy.

Also there are multiple of them so i might need it to be a script.parent instead of workspace.PartToDestroy

1 Like

here is better code to paste:

local PartToDestroy = script.Parent
local ClickDetector = PartToDestroy.ClickDetector

ClickDetector.MouseClick:Connect(function()
PartToDestroy:Destroy()
end)

That should work and do not worry I am not busy

1 Like

Again thank you so much. Have a good day

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.