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

I tried making a Leader Queue script, but it isn't working. What is wrong with it?

Asked by 3 years ago

Hello. I am trying to make a game where you need to survive and when the leader dies, the person in position one of the queue becomes the next leader and moves the leader that died to the back of the queue. I am getting no errors in output, it just doesn't work? Here is the script:

local leaderDead = false

game.Players.PlayerAdded:Connect(function(plr)
    if game.Workspace.leaderQueue.Surface.board.CurrentLeader.TextLabel.Text == '' then
        game.Workspace.leaderQueue.Surface.board.CurrentLeader.TextLabel.Text = plr.Name
        leaderDead = false
    elseif game.Workspace.leaderQueue.Surface.board.QueuePos1.TextLabel.Text == '' then
        game.Workspace.leaderQueue.Surface.board.QueuePos1.TextLabel.Text = plr.name
    elseif game.Workspace.leaderQueue.Surface.board.QueuePos2.TextLabel.Text == '' then
        game.Workspace.leaderQueue.Surface.board.QueuePos2.TextLabel.Text = plr.name
    elseif game.Workspace.leaderQueue.Surface.board.QueuePos3.TextLabel.Text == '' then
        game.Workspace.leaderQueue.Surface.board.QueuePos3.TextLabel.Text = plr.name
    end
    local currentLeader = game.Workspace.leaderQueue.Surface.board.CurrentLeader.TextLabel.Text
    while true do
        if game.Workspace[currentLeader].Humanoid.Health == 0 then
            leaderDead = true
        end
    end
    if leaderDead == true then
        game.Workspace.leaderQueue.Surface.board.QueuePos3.TextLabel.Text = currentLeader
        game.Workspace.leaderQueue.Surface.board.CurrentLeader.TextLabel.Text = ''
    end
end)

I really need this script for my game, help would be greatly appreciated! Credit will be given for helping with the script

Answer this question