If you want a player's character, do player.Character. If you have a model and want to know if it's a player's character, do game.Players:GetPlayerFromCharacter(model). In your case, it looks like you want to know the number of players that have an IsLoaded boolean value that is set to true.
Notes about your current script:
- You only run your script if there is only 1 player in the game. Are you sure you didn't want it to be
>= 2 on the first line?
- You should never
WaitForChild in a for loop - imagine if IsLoading is never added (ex maybe the player leaves or a script breaks) and WaitForChild never returns? Instead, use FindFirstChild, assigning the result to a local variable.
- You set
status.Value every time you find an IsLoaded value that is true. Is
Recommended script:
function GetNumPlayersLoaded()
local p = game.Players:GetPlayers()
local char, isLoaded
local num = 0
for i = 1, #p do
char = p[i].Character
isLoaded = char and char:FindFirstChild("IsLoaded")
if isLoaded and isLoaded.Value then
num = num + 1
end
end
return num
end
if GetNumPlayersLoaded() < 2 then
status.Value = "There needs to be 1 more player to begin!"
end
Notes about this script:
- I made the function GetNumPlayersLoaded so that you can use it in multiple places in your script
- It uses
game.Players:GetPlayers() so that it will only get actual players rather than all children that happen to be in game.Players (though usually this is the same thing)
- If a player doesn't have an
IsLoaded value in their character, it is assumed that they are not ready
- The last 3 lines should be put where-ever you need them; the function should be placed at the top of your script (or at least in a place before you call it)
2 comments
You could have it search the player list for the name of the player instead.
I don't understand what and why you do stuff in your code.