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

How would i teleport a certain player to a brick as soon as it spawns in the workspace?

Asked by
lopte1 -5
4 years ago

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!

1 answer

Log in to vote
0
Answered by 4 years ago

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.

0
So I read into what you told me, and I did everything you said to do and wow I gotta say thx it really helped. I went with the scripting way just bc it worked better with what I wanted to do. But do you think I could somehow only make the script fire when the enters the workspace? because basically right now I have it stored in lightning and what I would want it to do is teleport the player to the lopte1 -5 — 4y
0
brick as soon as the brick "appears" in the workspace. It might seem a bit unclear i can probably help you clear things up if you have any question, thanks in advence i really appreciate it. lopte1 -5 — 4y
0
Oh... I misread the question aha. I have two questions about this though: 1. Which player(s)? 2. How is the brick appearing in the workspace? Is a script creating a new instance? User#25069 0 — 4y
Ad

Answer this question