I'm trying to teleport players to a certain block when there are a certain number of players in the game (I put 0 just to test it out). The teleport works if I put in actual coordinates, but once I fill it with the variable it doesn't.
playernumber = #game.Players:GetChildren()
islandposition = game.Workspace.Islands.Island1.Position.Unit
target = CFrame.new(islandposition)
if playernumber>0 then
for i, player in ipairs(game.Players:GetChildren()) do
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end

5 comments
I tried using that and I might be doing something incorrectly, but it didn't work. Is there any way to fix the code in the way I tried it? You explained my problem, but I'm not sure I understand it. (I tried replacing those two things and it didn't work).
My main question though, is if target = CFrame.new (2,4,10) works, then why won't target = CFrame.new (islandposition) work if islandposition = 2,4,10
Mainly because that's not how you define the CFrame location in a variable in RbxLua. What you should have done instead is say target = islandposition.CFrame;
Miike0, has my answer satisfied you? If so could you mark my answer as the solution?
Yeah, sorry for the late response. I haven't been able to get this to work. It just keeps teleporting me downward.