I'm making a game that has a cash IntValue in it and it says that Players.CreeperAssassin005.Backpack.RustyShovel.Script:13: attempt to index local 'player' (a nil value). Any help?
script.Parent.blade.Touched:connect(function(hit)
if script.Parent.CanDamage.Value == true then
script.Parent.CanDamage.Value = false
hit.Parent.Humanoid:TakeDamage(20)
if hit.Parent.Humanoid.Health == 0 then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local money = player.leaderstats.Cash
money.Value = money.Value + 999999
end
end
end
end)

4 comments
It doesn't have any error messages but it doesn't give my the money...
Using Print I figured out that the code stops at if player ~= nil then, so this code doesn't work in this state.
Line 12 has to go after line 13...
^already tried that