Tweening everyones camera

I should’ve added a print in teleportAllPlayers for print(roundInfo.Players:GetChildren()) it seems like it may be empty if nothing else is printing. Are you getting any errors?

does not print, here is the main script again for reference as i will not be online for a little:

dont steal my code >:(

Alright, if there’s no errors and no table printed, it could just be empty, make sure roundInfo.Players is actually being populated with players, should be able to be something you can see in the workspace when you’re in play test mode. I actually dont see where teleportAllPlayers is even called, but you said it prints so I assume it’s just in some script I haven’t seen. So yeah that’s all I can think of anyways is Players not being filled up and something that happened between post 8 and 9 maybe had been accidentally removed.

2 Likes

its called right here:

dont steal my code >:(

there is nothing in the folder, maybe because they are not being teleported?

If there’s nothing in the folder it means you’re not adding them. I’m not sure how you want to add players to this folder, but if you just want to add everyone at the start you could loop over all players and make string values, then parent the string values to the folder with the name of the player as the name of the instance. Or you could just use Players in general and not use the folder. There’s many ways to go about doing it. I personally wouldn’t do it this way, I’d keep it in a table in memory and not have anything in the workspace, but here’s a possibility if you just want to add all players to the folder:

for i, p in ipairs(game.Players:GetChildren()) do
  local val = Instance.new("StringValue")
  val.Name = p.Name
  val.Parent = roundInfo.Players -- given roundInfo is game:GetService("ReplicatedStorage").RoundInfo
end

I would do something more like:

local playersInGame = {}
for i, p in ipairs(game.Players:GetChildren()) do
  table.insert(playersInGame, p)
end

and then use playersInGame and pass it to scripts as needed, but honestly it’s whatever if you need to have them in a folder, the top one works.

1 Like

both of them turn out with ServerScriptService.GameLogic:13: invalid argument #1 to 'ipairs' (table expected, got Instance) and im pretty sure gamePlayers is supposed to be different than Players

1 Like

That’s because I’m an idiot and forgot :GetChildren() Whoops. Edited the original to fix that.

1 Like

still getting the same error on the table.insert(p) line, how about changing (p) to the RoundInfo.Players folder?

This just goes to show why you should sleep at 2 AM instead of coding, it’d be table.insert(playersInGame, p). Regardless, if you want to put them in the folder use the first snippet:

for i, p in ipairs(game.Players:GetChildren()) do
  local val = Instance.new("StringValue")
  val.Name = p.Name
  val.Parent = roundInfo.Players -- given roundInfo is game:GetService("ReplicatedStorage").RoundInfo
end
1 Like

lol true what about these lines?

dont steal my code >:(

Ok, I suppose we should clear something up. How do you want players to be added to this list? On join? A GUI button click? Stepping on a part, etc?

Also,

while #gamePlayers:GetChildren() < 0 do --testing purposes
	wait()
end

Not sure if this is what you mean by testing purposes, but this will never run. The length of a GetChildren() call is always 0 or more (unless the instance is nil, then it just errors). Maybe you meant <= instead of just <

On join for now, and actually it does run, it was 0 before so if i were to Run the game, the round would still work

If it’s on join that I’d use

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	local val = Instance.new("StringValue")
	val.Name = player.Name
	val.Parent = roundInfo.Players
end)

So when a player joins, a new string value will be added to the folder with the same name as the player, but the value is just empty. I’m just using a string value here because you’re using .Name in other places, though it could technically be any instance, string values are just easy to make, don’t take up any actual 3d space, and just kinda sit there.

You could even extract adding a player into a function in your player module. Something like

function playerModule.addPlayer(player)
    local val = Instance.new("StringValue")
    val.Name = player.Name
    val.Parent = roundInfo.Players
end

ill try that, just found out where gamePlayer is actually created, in PlayerModule here

dont steal my code >:(

Well them the problem is in intermission, you clear all the children of gamePlayers, which means it’s empty because you’re never re-adding players after clearing them because you only add on join

1 Like

the point is to clear it after the game ends, so while in the intermission there is no gamePlayers, when a game starts there is

That’s fine, but you’re not adding players after, so when you call teleportAllPlayers, there’s no players in the folder because you cleared the folder. Right now you add them only when they join the game (that I can see), when the game starts, the folder with all the players is cleared. If you just want to do testing purposes, you should comment out the line that clears the folder in intermission, then when you decide how you want to add players in the intermission you can uncomment it again.

i did do that, and it worked, but i still want gamePlayers to have a use, so i shouldve said

Alright, if it worked, what other problems are you having? Also, we should bring this to private messages because this has gone really off topic from the original post.

1 Like