Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesnt the player get teleported as he spawns in?

So, I made this one script who teleports the player to the last login location:

game.Players.PlayerAdded:connect(function(player)
	wait(1)
local	p1 = player.Time.position1.Value
local	p2 = player.Time.position2.Value
local	p3 = player.Time.position3.Value
	player.Character.HumanoidRootPart.CFrame = CFrame.new(p1,p2,p3)
end)

but for some reason it only works in roblox studio but not in an actual server, any ideas of what I could have done wrong?

2 answers

✓ Accepted answer

Might I suggest you use the CharacterAdded Event?

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:wait()
local   p1 = player.Time.position1.Value
local   p2 = player.Time.position2.Value
local   p3 = player.Time.position3.Value
    player.Character.HumanoidRootPart.CFrame = CFrame.new(p1,p2,p3)
end)

Explanation: In studio, everything is loaded. This is not the case in a server. You must wait for the character to load, which might take longer than 1 second. If that doesn't fix it, it will still help as this is a lot better than only waiting 1 second.

game.Players.PlayerAdded:connect(function(torso) --Changed parameter to torso for Torso in localplayer
    local player = game.Players:GetPlayerFromCharacter(torso.Parent)
   local character = player.Character
  local T = character.Torso
    wait(1)
local   p1 = player.Time.position1
local   p2 = player.Time.position2
local   p3 = player.Time.position3
    player.Character.Torso.CFrame = CFrame.new(p1.Value,p2.Value,p3.Value)
end)

3 comments

0

The Pos cannot be in one variable since I am saving it in an int value table

0

oh

0

You need to have a Vector3Value

This discussion is preserved as it was. New answers, comments, and votes are closed.