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

[Solved]How can I teleport a player to another player without getting stuck in surrounding objects?

I am working on a project for someone and they asked me to script a command where a certain rank person can say :assist and a higher rank person will be teleported to them(in game of course). At first I thought I would just use the CFrame of the player that I am teleporting to and add a certain amount to the y. However, I thought about ceilings and realized my idea was not so great after all. Is there any way I can check around a player for an empty space to spawn in. Note: I am asking for a method not a script. Thanks!

8 comments

0

Raycasting

0

are you sure?

0

can I use a for loop and when an open space is found return that area?

0

is it possible to break out of a for loop?

0

If you change the player's HumanoidRootPart.Position, roblox will check if it has enough space, and if it dosen't it will bump up the Y axis until it does.

0

I would recommend when you teleport the player, add a little offset of maybe a Vector3.new(0, 0, 15). Just an idea

0

@incapaz, what if there's a wall at the offset?

0

ok thanks guys! I am planning on doing an offset after casting a ray in that direction. We will see if it works.

2 answers

Maybe you can use a script that will make you go threw the surrounding objects....Maybe find on YouTube? Note: Dont use AlvinBlox, people told me he's bad.

use rays and :FindPartOnRay(Ray) to calculate how big an area is then tp or disable player to player collision and do :SetPrimaryPartCFrame(Teleportingtoplayersprimarypart.CFrame)

1 comment

0

make sure its the ray hit position and not the part position

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