How to get leaderstats from hit?

I am not sure how to get leader stats from a hit. When the player dies he should remove 100 Candy from his leader stats but I use a function and the hit from the parenthesis

local leaderstats = hit.Parent:WaitForChild(“leaderstats”)
local Candy = leaderstats.Candy
Candy.Value = Candy.Value - 100

the player dies but doesn’t remove the 100 am I using the wrong idea?

It gets reset cause hit.Parent is the Character and not the Player. Use game.Players:GetPlayerFromCharacter(hit.Parent) instead of hit.Parent

1 Like

Oh, thank you. I’ll try that :smiley: