Hello. I have a Scripting question. So, I am trying to make a game where basically a player gets teleported on a stage for 45 seconds, and then after that 45 seconds, that player gets teleported back to spawn. So basically, a random player gets teleported to a part for a specific amount of time (the stage), and after that amount of seconds, they get teleported back to another part (which is the spawn) Help would be appreciated. If you don't understand but want to help, please ask so.
So far, this is what I have put to select a random player:
wait(5)
local num = math.random(1, #game.Players:GetChildren())
print(game.Players:GetChildren()[num])
local player
Then, I have tried making it so it teleports the player:
wait(5)
local num = math.random(1, #game.Players:GetChildren())
print(game.Players:GetChildren()[num])
local player
player.CFrame = CFrame.new(11.667, 23.652, 95.261) -- position
player = nil
The problem is that it doesn't teleport the player and an error says "attempt to index nil with 'CFrame' ". Please help me fix it so it actually teleports the player and make it so it after 45 seconds it teleports that player back to another block (the spawn)

1 comment
oh i understand now!