Script error support

Hi, Im working on a game but am not a good scripter.
Im trying to get this script to work. Can anyone explain?

Script

script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA(‘Humanoid’)
if humanoid then
humanoid:TakeDamage(10)
if humanoid.Health < 1 then

local kills = game.Players.LocalPlayer.leaderstats.kills
kills.Value = kills.Value + 1
end

end
end)

Error

Workspace.maturegotit.Tool.damage.damage:7: attempt to index nil with ‘leaderstats’

Does the leaderstats folder already exist?

Boolvalues don’t support numbers.

Avoid experimenting with formatting during discussions. You can do that with Discobot in DM’s.

Are you running this from a local script?

LocalPlayer is only usable in LocalScripts.

What you can do is attempt to get the killer, then set a variable for Players:GetPlayerFromCharacter(value of the killer instance here).leaderstats.kills

Then you can carry out the rest of your script.

1 Like