I'm trying to make this when zombie gets kills it adds 8 heads to the leaderboard but its not working!!! please help
local Humanoid = script.Parent.Zombie -- Or Zombie Or Whatever function PwntX_X() local tag = Humanoid:findFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then local Leaderstats = tag.Value:findFirstChild("leaderstats") if Leaderstats ~= nil then Leaderstats.Heads.Value = Leaderstats.Heads.Value + 8 wait(0.1) script:remove() end end end end Humanoid.Died:connect(PwntX_X)
Be sure you actually create the leaderboard and properly tag your coding so it is easy to read. To create the leaderboard, you have to create a separate script to address when a player enters. Here is an example code of leaderboard creation.
local pls = game:GetService("Players") OnEnter = function(player) local leaderstats = Instance.new("IntValue",player) leaderstats.Name = "leaderstats" local heads = Instance.new("IntValue",leaderstats) heads.Name = "Heads" heads.Value = 0 end pls.PlayerAdded:connect(OnEnter) --Just to make sure everyone gets one local a = pls:GetChildren() for i=1,#a do OnEnter(a[i]) end