Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Character won't teleport right after player spawns?

Asked by 9 years ago

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?

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. DigitalVeer 1473 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

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

Ad
Log in to vote
0
Answered by 9 years ago

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.

Answer this question