Well, the title i could say explained everything, here's the code.
function workended(part) local parent = part.Parent if game.Players:GetPlayerFromCharacter(parent) then parent.Humanoid.Health = 0 local player = game.Players:FindFirstChild(parent) if player then player.leaderstats.Money.Value = player.leaderstats.Money.Value + script.Parent.Parent.Value end end end script.Parent.Touched:connect(workended)
And when i step on it i get killed and dont get money. And yes, i checked the value and the value was actually 10 (it was meant to be also) Here's a screenshoot to prove that everything with the leaderstats is fine. http://prntscr.com/ceuw0u
Is there any error?
...Don't use :FindFirstChild
to get the player... use :GetPlayerFromCharacter
like you almost did.
local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then hit.Parent.Humanoid.Health = 0 player.leaderstats.Money.Value = player.leaderstats.Money.Value + script.Parent.Parent.Value end
Try BlueTaslem's answer but also try making the leaderstats a folder instead of a model. Not sure if that would make a difference but that did the trick for me one time so It might work for you.