So I am making this game and when I kill the npc it's suppose to give you a point. can anyone fix this pls?
local humanoid = script.Parent:FindFirstChild("Humanoid") local player = game.Players:FindFirstChild(humanoid.Parent.Name) if humanoid.Health == 0 then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10 player.leaderstats.Coins.Value = player.leaderstats.Levels.Value + 1 end
The script you provided would only give a point to the player when the player dies as soon as the server is made, which I assume is not what you are trying to achieve. To fix this you would need to define the humanoid as the humanoid of the NPC and the player as game.Players:GetPlayerFromCharacter(script.Parent), and rather than checking if humanoid.Health == 0
it should be humanoid.Died:Connect(function()