Im working on a script to teleport a specific player to a specific brick as soon as it enters the workspace, I've got it to work but my problem is it checks evry 10sec to see if in the workspace and well after 10 seconds if it's not it just breaks. How should I go about doing this? Thx!
If you want to use a SpawnPosition, those are easy. Just insert one into the workspace and place it where you want the players to spawn. However, if you wish to use a script:
What you want to do is as soon as the character is spawned into the work space, it teleports. By putting a script in StarterPlayer > StarterCharacterScripts, you can have the script run as soon as the character is spawned. (You may have been using game.Players:PlayerAdded() which fires when the player is added rather than the character).
What you'll want to do in this script is teleport the HumanoidRootPart (the part within the character that can be moved/teleported without the player dying instantly) to the part in question plus a few blocks higher so that the player isn't stuck inside it.
Start with
local HumanoidRootPart = script.Parent.HumanoidRootPart local part = workspace.part --change this to the part you want to teleport the player to
Now that you have the part you want to teleport and where you want it to go, you need to go about doing it.
local HumanoidRootPart = script.Parent.HumanoidRootPart local part = workspace.part HumanoidRootPart.CFrame = part.CFrame
You could leave it here, but this script currently would teleport the player to the center of the part and they would be stuck inside it. So, you'll want to teleport them a little bit higher.
To do this, you need to add a few studs on the vertical axis, which is done simply by:
local HumanoidRootPart = script.Parent.HumanoidRootPart local part = workspace.part HumanoidRootPart.CFrame = part.CFrame + CFrame.new(0, 3, 0)
Half way through writing this, I realised you could just use a SpawnPosition, but I've decided to include this bit anyway.