I made this code which gives cash to a player when they click on a part they get cash. How would I add the condition that if a player has already clicked on the same part then they can't press it again but they can press on other parts which have the same clickdetectorevent.
My ClickdetectorEvent Code:
workspace.MyClickDetectorEvent.OnServerEvent:connect(function(plr)
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + (1000)
end)
Each part has a clickdetector and has the fire event code in localscript in startergui
How would I make it so that if a player has already clicked on the part once then they cant get cash if they press again but they can click on a different part with the same event and still get cash.
The code i made so that if a player has already clicked on the part they wont get cash again however this caused player s unable to click on another part which has the same click detector event but in my game players should be able to.
local connection
connection = workspace.MyClickDetectorEvent.OnServerEvent:Connect(function(plr)
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 5
connection:Disconnect()
end)

4 comments
That, my friend. I don't know :P
oh ok
u need to hav brain soemthing u dont hav
probably need a datastore or something idk