How To Make Click Detector Add Coins when NPC died?
To put a condition to collect the point, only when the character is simply dead. how can i do this using the script below? the model is Judoon. I tried something, but it does not come out for me, because he unlocks the button permanently add coins, does not resume the condition every time.
so if the character Judoon is dead, will collect 10 points. if the character is alive, it will not collect the 10 points.
local CanClick = script.Parent:WaitForChild("CanClick") local ClickDetector = script.Parent modelname = "Judoon" -- Model name model = game.Workspace:FindFirstChild(modelname) local function onClick(playerClicked) if (playerClicked and CanClick.Value ~= false and model:FindFirstChild("Humanoid") ~= nil) then CanClick.Value = false local Leaderstats = playerClicked:FindFirstChild("leaderstats") if (Leaderstats and Leaderstats.Coins) then Leaderstats.Coins.Value = (Leaderstats.Coins.Value + 10) end wait(1) CanClick.Value = true end end ClickDetector.MouseClick:Connect(onClick)

9 comments
unlock the permanent button. it does not resume the condition every time the character repawns. after the Judoon is killed once, they can collect the points, before they are killed, they cannot collect them. it is ok so far, the problem is that after that they can collect the points and do not resume their condition again.
it is the same problem that I encountered up top, it works the first time, when the character repawns, it simply collects the points continuously.
Could you explain how it "respawns"?
I edited the post.
Try the code I edited
now it works, but after it no longer collects the point, I can collect only once. when the character returns, it no longer collects the point when you press the button again.
it should be something like, canCollect: Connect () at the beginning, and after disconnect ()
Here: I’ll update the code to handle this. Just ensure you put the script within the PrimaryPart (Or whichever part of the Judoon wish you to be allowed to be clicked).
I managed to do what I wanted very simple, modifying simple script clicker collect and introduced it into the respawn. all I wanted was to collect the point when I clicked the button, but only after the character was dead. thank you very much for your help!