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

Character won't teleport right after player spawns?

I have a script that manually loads a character and teleports that player's character to a certain part's position. Here's the script:

script.Parent.loadcharacter.Value = true -- Since :loadcharacter() can only work in a regular script, I made a value and put a Changed function inside the value so that whenever the value changes, the player respawns
repeat wait() until game.Players.LocalPlayer.Character
game.Players.LocalPlayer.Character.Torso.CFrame =
CFrame.new(game.Workspace.teleportPlayerHere.Position)

The problem is that the player doesn't move. I tried putting wait(2) before the player teleports and after the player respawns, which worked, but I want it to do it as fast as it can. Any help?

1 comment

0

Try using ':wait()' on certain things. Such as "local plr = game.Players.LocalPlayer or game.Players.LocalPlayer:wait()", and "local chr = plr.Character or plr.Character:wait()", the ':wait()' which is built in for objects also works on properties.

2 answers

Try copying the "teleportPlayerHere" part's CFrame numbers into the brackets, see if that will work.

I'm not sure I understand what you're trying to do. Why are you using repeat wait() until? It just creates an infinite loop that does absolutely nothing. Additionally, you passed the code you want to run as an argument to a loop, while it expected a bool. Learn how to use repeat until here. You should also include a tree, and say what type of script is where. If you want to teleport a player to a specified part or position when he spawns, you can put a local script in StarterPack or StarterGui that teleports the player to the desired location, or you can use the PlayerAdded() and CharacterAdded() events in a default script.

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