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

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

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

1 comment

0

No output as in the print statements are not printing at all? Or there is no errors?

1 answer

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                                     

4 comments

0

Use spawn() to run the function in the background

0

the problem is that when line 8 runs, no players are connected, so it don't connects the event at line 9

0

Oh yeah

0

No need to downvote, I was just trying to help.

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