Why can I not position a player?

So I’m trying to make when you join the game you will be teleported first to somewhere, but when I use this script I don’t have any errors, it’s simply just doesn’t work.

local player = game.Players.LocalPlayer

wait(5)

game.Players.PlayerAdded:connect(function(player)
	player.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(game.Workspace.TP.CFrame)
end)

script is in serverscriptservice, meaning it’s a serverscript.

1 Like

Because the player joins before playeradded is connected.

Even without wait it wouldn’t work.

local players = game:GetService("Players")

local function playeradded(player)
    
end

for i,v in pairs(players:GetPlayers()) do
    coroutine.wrap(playeradded)(v)
end

players.PlayerAdded:Connect(playeradded)

its because you are using CFrame.new on a value which is already CFrame try this:

local player = game.Players.LocalPlayer

wait(5)

game.Players.PlayerAdded:connect(function(player)
	player.Character:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.TP.CFrame
end)

I want it to teleport only one player, I don’t get this code

afbeelding

??

Script in server script service:

game.Players.PlayerAdded:connect(function(player)
	player.Character:WaitForChild("HumanoidRootPart").CFrame = workspace.TP.CFrame
end)
1 Like

afbeelding

Same thing

If you are trying to teleport the player in a local script do this

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait() -- Gets the players character

its because it hasnt loaded yet try this

game.Players.PlayerAdded:connect(function(player)
  player.CharacterAppearanceLoaded:Connect(function(Character)
	  Character:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.TP.CFrame
  end)
end)
1 Like

You have to wait for the player.character’s appearence added. nil in the error refers to you script running before the player’s character is even added. I usggest using Player:CharacterAdded:Connect() and running your script inside of that.

1 Like

What’s the difference between teleporting it on the client or the server,

No but that will teleport the player EACH time the player respawns, I only want it to teleport to the place each time it joins.

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:Connect(function(char)
 
 
 
 
char:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.TP.CFrame
    end)
end)

Read this.

Same thing what i said here

Look we are here only to help you come to a solution. Please try to solve it yourself.

I already tried, YouTube doesn’t help and stuff, now i’m here.

game.Players.PlayerAdded:connect(function(player)
    local char = player.Character or player.CharacterAdded:Wait()
char:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.TP.CFrame
end)
1 Like