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

Can anybody help me?

Asked by 10 years ago

Hi, I'm a beginner to Lua and was trying to make a custom leaderboard. It doesn't work too well.

Here's the leaderboard setup, the problem here is that it's only giving it to one player (the first one in the server).

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model", player)
    leaderstats.Name = "leaderstats"

    local stars = Instance.new("IntValue", leaderstats)
    stars.Name = "Stars"
    stars.Value = 0

    local points = Instance.new("IntValue", leaderstats)
    points.Name = "Points"
    points.Value = 0
end)

Another issue is with this script, where I'm trying to give players "Stars" every time they touch a block. It works, but again only with one person. I also need it so that when someone touches the block everybody gets teleported back to the spawn(s).

script.Parent.Touched:connect(function()
    for _,Player in pairs(game.Players:GetPlayers()) do
        if Player:FindFirstChild("leaderstats") then
            Player.leaderstats.Stars.Value = Player.leaderstats.Stars.Value + 1
        end
    end
end)

My last question is how to make a script so that when someone kills someone they get a "Point".

If anybody could help me, it would be greatly appreciated.

(I also need to add data store, but I'll figure that one out later.)

Answer this question