Hello I was wonder if anyone knows how to disable clickdetector when you clicked once.
Heres the script:
local GivePart = script.Parent.GivePart
local ClickDetector = GivePart.ClickDetector
local Cup = game.ReplicatedStorage.Cup
ClickDetector.MouseClick:Connect(function(PlayerWhoClicked)
print("Clicked!")
script.Parent.cup1.Transparency = 1
local CupClone = Cup:Clone()
CupClone.Parent = PlayerWhoClicked.Backpack
end)
1 Like
Set the MaxActivationDistance to 0
You could use the Destroy()
method against the ClickDetector object once it’s been clicked to remove it entirely.
Or, if there is case where you’d use the ClickDetector again, you could create a BoolValue
object underneath and set it’s value to true
. Then simply add a check to see whether the ClickDetector’s bool is true or not.
If you’d like to run it for multiple players, you could create an array and add the player names of the players who have clicked the detector - then add a check to see whether the player’s name is already in the array using the table.find
function.
Hope this helps,
-Tom 
Thanks for the support! But I did this:
ClickDetector.MouseClick:Connect(function(PlayerWhoClicked)
print("Clicked!")
script.Parent.cup1.Transparency = 1
local CupClone = Cup:Clone()
CupClone.Parent = PlayerWhoClicked.Backpack
GivePart.ClickDetector.MaxActivationDistance = 0
end)