So I got this error after I re-enabled my server script (handles everything in the server side of the game)
The error in the output shows: [ Character is not a valid member of Sky]

on first I didn’t even know what this is, I didn’t even know this was a thing, I don’t even have a line of code where it redirects to the lighting or skies something like that
local function teleportPlayers()
local spawns = currentmap:FindFirstChild(chosenmap.Value).Spawns:GetChildren()
for _, Player in pairs(Players:GetChildren()) do
Player.Character.HumanoidRootPart.CFrame = currentmap:FindFirstChild(chosenmap.Value).Spawns.Part.CFrame + Vector3.new(0, 10 ,0)
table.insert(contestants, Player)
connections[Player.Name] = Player.Character.Humanoid.Died:Connect(function()
table.remove(contestants, table.find(contestants, Player))
Player.Character.Humanoid.WalkSpeed = 0
end)
end
end
Player.Character.HumanoidRootPart.CFrame = currentmap:FindFirstChild(chosenmap.Value).Spawns.Part.CFrame + Vector3.new(0, 10 ,0)
here is the code which caused the error
All help is appreciated 
Are you sure Players
is game.Players
and not something else because that’s like the only way this error can occur.
I used Players as
game:GetService("Players")
Then it should work fine unless you accidentally turned Players
to something else at some point in your code.
1 Like
So I solved the problem, Instead of defining Player using the Players service I defined Player in the for loop as
local function teleportPlayers()
local spawns = currentmap:FindFirstChild(chosenmap.Value).Spawns:GetChildren()
for _, Player in pairs(game.Players:GetPlayers()) do
Player.Character.HumanoidRootPart.CFrame = currentmap:FindFirstChild(chosenmap.Value).Spawns.Part.CFrame + Vector3.new(0, 10 ,0)
table.insert(contestants, Player)
connections[Player.Name] = Player.Character.Humanoid.Died:Connect(function()
table.remove(contestants, table.find(contestants, Player))
Player.Character.Humanoid.WalkSpeed = 0
end)
end
end
Edit: I still didn’t know why using the Players service dont work .-.
This may because you have an object called Sky in your player service?
Also, happy birthday person above.
2 Likes
I forgot that you can put other objects inside PlayersService that’s not a player object. But why would anyone do that though?
Also thanks.
1 Like
Yeh I asked that before, and I was like WHAT!? I mean why not just use GetPlayers over GetChildren. I mean sure but it’s literally the Player Service.
1 Like
Because nobody excepts someone to put an object inside players so normally there wouldn’t be any difference between :GetChildren()
and :GetPlayers()
.
1 Like