local human = game:GetService("Players") script.Parent.MouseClick:Connect(function(player) local getCookies = player.leaderstats.Points if getCookies.Value == getCookies.Value then getCookies.Value = getCookies.Value + 1 end if getCookies.Value <= 10 then return end if getCookies.Value > 10 then local chr = human:GetPlayerFromCharacter(player) local humanoid = chr.Humanoid if humanoid then humanoid.Health = 0 end end end)
So I'm trying to make so that when you click on a 'Part', it will do nothing but give you points UP UNTIL you hit 10+, if u hit 11 points you will die.
How do I correct this error?
Hello,
It appears that you have incorrectly assigned your variables.
Simply replace your code with the following:
script.Parent.MouseClick:Connect(function(player) local getCookies = player.leaderstats.Points if getCookies.Value == getCookies.Value then getCookies.Value = getCookies.Value + 1 end if getCookies.Value <= 10 then return end if getCookies.Value > 10 then local chr = player.Character or workspace:WaitForChild(player.Name) --correctly finds player's character and waits if character is unloaded local humanoid = chr.Humanoid if humanoid then humanoid.Health = 0 end end end)
Hope this answer helped you!
Cheers,
Chase