#how do u make the wait skip if the leader left

96 messages · Page 1 of 1 (latest)

wide kraken
#

ima send it in 2 message bc too long


wait(5)

local function visiblefalse(gui)
    gui["leader panel button"].Visible = false
    gui["Leader GUI"].Visible = false
    gui["sword panel"].Visible = false
    gui["announcement panel"].Visible = false
    gui["jail player panel"].Visible = false
    gui.guardpromo.Visible = false
end
#
while true do
    local players = game.Players:GetPlayers()
    local num = math.random(1, #players)
    local player = players[num]
    local teamservice = game:GetService("Teams")
    local leader = teamservice:FindFirstChild("Leader")
    local immigrant = teamservice:FindFirstChild("Immigrant")
    local prisoner = teamservice:FindFirstChild("Prisoner")

    local hasLeader = false
    for _, plr in pairs(players) do
        if plr.Team == leader then
            hasLeader = true
            break
        end
    end
    
    local playerLeft = false

    game.Players.PlayerRemoving:Connect(function(player)
        if player == player then
            playerLeft = true
        end
    end)

    for _, plr in pairs(players) do
        local gui = plr.PlayerGui.ScreenGui
        visiblefalse(gui) -- Move this line outside the if statement

        if plr == player and not hasLeader then
            if plr == player then
                gui["leader panel button"].Visible = true
                print("visible true")

                if player and leader then
                    player.Team = leader
                    print("leader true")
                end

                if player and immigrant then
                    local waitTime = 100
                    if playerLeft then
                        wait()
                    else
                        wait(waitTime)
                    end

                    if not playerLeft then
                        visiblefalse()
                        player.Team = immigrant
                        print("immigrant true")
                    end
                end
            end
        else
            print("elses true")
        end

        if plr ~= player and immigrant then
            plr.Team = immigrant
            print("last part true")
        end
        if plr == player and hasLeader then
            visiblefalse(gui)
        end
    end
end
#

so i want if the leader left the game, it will instantly pick a new leader without waiting

#

how do u do that

#

i tried using playerremove thing but it didnt work, i tried it in studio

#

so how do u do it

wide kraken
mellow summit
#

its okeh

wide kraken
#

me brain broken

mellow summit
#

what to do

#

it seems all good

wide kraken
#

no no

#

so like

#

i want it if the leader left the game

#

it will not wait and just instantly find a new leader

mellow summit
#

then delete]

#

the wait

#

brah

wide kraken
#

idk how to delete the wait if the player leave the gamne

#

can u edit scriptikaa

#

dawd

#

pls

#

my brain hurt

mellow summit
#

just

#

delete

#

the first wait

wide kraken
#

ok

#

and then it will work?

mellow summit
#

it worked before but slower

#

so why wouldnt it work

wide kraken
#

idk

#

it just dont work

#

where do i put the script

#

i tried putting in serverscriptservice but it bugged

#

like very buggy, startergui less bug but still bug

#

@mellow summitthe thing no work

#

it didnt skip the wait, it just keep waiting

#

player left, it just keep waiting

mellow summit
#

if it wait then if work after the wait end?

wide kraken
#

what

#

what r u saying

#

so the script didnt detect the player leaving the server, it just kept going, PLS TELL HOW FIX P[LS

#

my brain dead

#

i am waiting, pls help me 😦

#

wait

#

'@mellow summit

#

i think it only work ingame not in studio

#

can u test it with me after i rest

wide kraken
#

@mellow summitcan u test

#

pls

#

add me

#

creeper_explotion83

#

or i send link at ur dms

#

pls

mellow summit
#

i dont join

#

people studios

#

try this

wide kraken
#

but

#

only once tho

#

if a player left the game, it select a new leader and if the plaeyr left again it wont like select another leader

#

also the gui isnt there when the script select a leader bc the old leader left

mellow summit
#

oh yah

#

forgot about that

mellow summit
wide kraken
#

NO WAY IT WROKED

#

@mellow summitexplain what u did

mellow summit
#

some of magic there and there

wide kraken
#

make it clear, ur my teacher

#

PLS EXPLAIN

mellow summit
#

I added a variable into RemovePlayer

#

event

#

and boom

#

made the gui Visible again

#

after player left

#

BOOM

wide kraken
#

state script u change and explain better

#

before it didnt work

#

now it work

#

explain

#

PLS

#

@mellow summit pls sensei

mellow summit
wide kraken
#

so like the variable checks if the player that left the game is the leader?

#

@mellow summit

#

mai maind ees explowdeing

#

bro u should make games in roblox, ur too good

#

where do u lua script

wide kraken
#

@mellow summiti need help

#

wait nvm

#

wait nvm i need ur help