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

Can't set teleport offset?

Asked by 6 years ago

So, my script works perfect the only problem is how can I make the players teleport to the spawn's location but have it offset a little? Here's the part of code I need help with.

Player.Character:MoveTo(Spawn.Position)

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You can add a few studs to the position by simply adding a Vector3.new() to it. This would look something like this, but with your choice of numbers:

Player.Character:MoveTo(Spawn.Position + Vector3.new(4,0,0))

That would make the character move 4 studs away on the x axis from the spawn position. You could also make it look a little neater by setting the Vector3.new() value as a variable like this:

local offset = Vector3.new(4,0,0)

Player.Character:MoveTo(Spawn.Position + offset)
0
But multiple players will spawn to that location at once so I needed them to spawn within a 15 stud diameter but not directly in the same place I know you can do that with math.random but I'm not sure how Michael_TheCreator 166 — 6y
0
simple, instead of setting offset as a specific set of numbers, set it as Vector3.new(math.random(1, how far you want it to go), 0, math.random(1, how far you want it to go)) cmgtotalyawesome 1418 — 6y
Ad

Answer this question