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

"Waiting System" is not working? (Explain Problem)

I am attempting to make a system that waits til all the players are in the game.

They is one server script that listens and see if a player joins. When a player joins it checks if they are a "Hunter" or "Survivor" through a data store. If they are a "Hunter" then it fires to the client to update GUI and put them on the Hunter side of the GUI. If they are a "Survivor" then it fires to the client to update GUI and put them on the Survivor side of the GUI.

Gif: https://imgflip.com/gif/1zzwyk

Server Script:

local Event = game.ReplicatedStorage.Events:WaitForChild("LobbyEvent")
local Players = game:GetService('Players')
local hunter = nil

game.Players.PlayerAdded:Connect(function(plr)
	print(plr.Name.." Has Joined")
	for i, v in pairs(game.Players:GetChildren()) do
		print("Checking through players 1st")
		for _, a in pairs(game.Players:GetChildren()) do
			print("Checking through players 2nd")
			if game.ServerStorage[plr.Name]:WaitForChild("Current").Value == "Hunter" then
				Event:FireClient(v, a.Name, "Hunter")
				print("It's A Hunter")
			elseif game.ServerStorage[plr.Name]:WaitForChild("Current").Value == "Survivor" then
				Event:FireClient(v, a.Name, "Survivor")
				print("It's A Survivor")
			end
		end
	end
end)

Client Script:


local HCard = game.ReplicatedStorage:WaitForChild("HunterCard")
local SCard = game.ReplicatedStorage:WaitForChild("PlayerCard")
local plr = game.Players.LocalPlayer
local Event = game.ReplicatedStorage.Events:WaitForChild("LobbyEvent")

Event.OnClientEvent:Connect(function(plr, Name, Position)
if Position == "Survivor" then
	if not script.Parent.Lobby.Main.LobbyFrame.Survivorlane:FindFirstChild(plr) then
		local SCardClone = SCard:Clone()
		SCardClone.Parent = script.Parent.Lobby.Main.LobbyFrame.Survivorlane
		SCardClone:FindFirstChild("Name").Text = Name
		SCardClone:FindFirstChild("Image").Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="
		SCardClone.Name = Name
	end
elseif Position == "Hunter" then
	if not script.Parent.Lobby.Main.LobbyFrame.Hunterlane:FindFirstChild(plr) then
		local HCardClone = HCard:Clone()
		HCardClone.Parent = script.Parent.Lobby.Main.LobbyFrame.Hunterlane
		HCardClone:FindFirstChild("Name").Text = Name
		HCardClone:FindFirstChild("Image").Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="
		HCardClone.Name = Name
		end
	end
end)

1 answer

You are forgetting to put wait() and inside the Parentheses put how much time in seconds do you want to wait for something to happen.

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