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

nothing functions after the CharacterAdded() function, any help?

Asked by
Ali_MTR 30
4 years ago

so im trying to make a 1v1 game and got stuck at making the gamemode

so anyway i need help trying to make my while true loop do anything

local players = game:GetService("Players")
local tPlace1Runnnig = game.Workspace.TrackingPlace1:WaitForChild("Running")
local tPlace2Runnnig = game.Workspace.TrackingPlace2:WaitForChild("Running")
local playerReadyTable = {}



for _,player in pairs (players:GetPlayers()) do
    player.CharacterAdded:Connect(function(character)
    while true do   -- here
        wait(3)
        print("help")
        print(#playerReadyTable)
        if character.IsPlaying.Value == false then
            table.insert(playerReadyTable, character.name)
            end
        end
        end)
end                                     

there are no output

any help would be appreciate it

0
No output as in the print statements are not printing at all? Or there is no errors? XviperIink 428 — 4y

1 answer

Log in to vote
0
Answered by
rabbi99 714 Moderation Voter
4 years ago

Because the while loop is active it keeps doing the stuff inside that loop and does nothing else.

local players = game:GetService("Players")
local tPlace1Runnnig = game.Workspace.TrackingPlace1:WaitForChild("Running")
local tPlace2Runnnig = game.Workspace.TrackingPlace2:WaitForChild("Running")
local playerReadyTable = {}



for _,player in pairs (players:GetPlayers()) do
    player.CharacterAdded:Connect(function(character)
        spawn(function()
            while true do   -- here
                    wait(3)
                    print("help")
                    print(#playerReadyTable)
                    if character.IsPlaying.Value == false then
                        table.insert(playerReadyTable, character.name)
                    end
                end
        end)
        end)
end                                     

0
Use spawn() to run the function in the background rabbi99 714 — 4y
0
the problem is that when line 8 runs, no players are connected, so it don't connects the event at line 9 Leamir 3138 — 4y
0
Oh yeah rabbi99 714 — 4y
0
No need to downvote, I was just trying to help. rabbi99 714 — 4y
Ad

Answer this question