Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This wont add anything to the leaderrboard?

Asked by
22To 70
9 years ago

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) 

1 answer

Log in to vote
0
Answered by 9 years ago

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
0
this wotn work 22To 70 — 9y
Ad

Answer this question