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

i need help making a leader script for my game any help? (btw it uses gui's and old scripts)

Asked by 6 years ago

this is the script

a = true
b = {}
c = {}
highest = 0
while a == true do
    wait (1)
    for _, Player in pairs(game.Players:GetPlayers()) do
        if Player.DataReady == true then

        PlayerName = Player.Name
        local survived=Player:LoadNumber("SurvivedTotal") or 0
        table.insert(b,PlayerName)
        table.insert(c,tostring(survived))

        d = 0
        for i,v in pairs(c)do
            d = d+1
            wait()
            if v > highest then
        highest = v
    end
        end
        script.parent.Text = (b[d]..": "..c[d])
        print (c[d])
        print (d)
        d = 0

script.parent.Text = (PlayerName..": "..survived)

        end
        d = 0
    end
    b = {}
    c = {}
    end

currently it doesent seem to do anything can anyone help?

0
You don't explain what this is suppost to do at all. R2D2yodayolo 32 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

So from what I can make out, the script above was supposed to pick which player has the highest value while displaying their name along with their score on a TextLabel.

--Script
local run = true
local highest = nil
local highestVal = -1

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

    local survived = Instance.new("IntValue",leaderstats)
    survived.Name = "SurvivedTotal"
    survived.Value = 0
end)

while run do
    wait(1)
    for i,v in pairs(game.Players:GetChildren()) do
        local survived = v:FindFirstChild("leaderstats").SurvivedTotal.Value
        if survived > highestVal then
            highestVal = survived
            highest = v
        end
        script.Parent.Text = v.Name..": "..tostring(survived)
        print(survived)
        print(i)
    end
end
0
thats not the way i want to do it ForgotenR4 68 — 6y
0
LoadNumber and DataReady are both deprecated. The code I provided does exactly the same thing as what you posted was supposed to do just without the tables. If you don't like it then modify to your liking. Meltdown81 309 — 6y
Ad

Answer this question