Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

1 comment

0

You don't explain what this is suppost to do at all.

1 answer

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

2 comments

0

thats not the way i want to do it

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.