I’m helping my friend develop his game, But when I tried to make it, It didn’t work, Is there any way to do this?:
What do you want to achieve?
A system that detects if all players are loaded, but since this game really focuses on single-player I don’t think It’s necessary but we have a plan to add multiplayer/co-op in the future soo please help!
What is the issue?
I already deleted the major scripts but I’ll include one that I didn’t delete at the bottom of this post
What solutions have you tried so far?
None
game.Players.PlayerAdded:Connect(function(Player)
local Char = Player.Character
local Hum = Char:WaitForChild("Humanoid")
Hum.Walkspeed = 0
local CharChildren = Char:GetChildren()
repeat wait()
until #CharChildren == 20
TypeText("Welcome to the tutorial!")
TypeText("Press A to move backwards and D to move forward")
TypeText("W to look up and S to crouch")
TypeText("Now GO!")
Char:WaitForChild("Humanoid").Walkspeed = 16
end)
CharChildren will be the same no matter when/where you print it. Let’s say once it’s defined, and the children in the character is at 15, CharChildren will be defined as a table containing only the 15 children present at the time of defining. This variable will not be re-defined once the child count updates, so you should use until #Char:GetChildren == 20.
local P = game:GetService("Players")
local t = {}
while not #t == #P:GetPlayers() do
wait(1)
table.clear(t)
for _,Plr in pairs(P:GetChildren()) do
if Plr.Character then
table.insert(t,Plr.Name)
end
end
end
Actually!, if you are referering to waiting for all player’s clients to load well you can but you shouldnt fully trust this, You could make clients fire a remote event to the server to tell the server when they finish loading using game:IsLoaded() however, exploiters can chose to never fire this signal there fore the game will never start, so if you plan on having this just add a maximum wait time where you start the game anyways after 10 seconds or something, Now if you are refering to the character be carefull too, since exploiters can delete instances parented to the character and get that replicated to the server, but if you do use :CharacterAppereanceLoaded(), Anyways hope that helped