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

3 comments
Boredlake I did what you asked but it just gives me an error about the leaderstats not working
Workspace.Dummy.Points on Death:5: attempt to index nil with 'leaderstats' - Server - Points on Death:5
local function onPlayerJoin(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local coins = Instance.new("IntValue") coins.Name = "Coins" coins.Value = 0 coins.Parent = leaderstats end game.Players.PlayerAdded:Connect(onPlayerJoin)