How do i make this

Untitled

its like a teleport system, ive tried to look around the devforum but found nothing that is like this

2 Likes

I assume your picture is depicting the NPC being teleported to lie on some circumference surrounding the player. How I would do that is by getting the direction from character → npc, which can be found with npc.Position - character.Position, then normalizing it (.Unit) and multiplying it by the radius of the “area” you drew. Looking like:

npc.Position = (npc.Position - character.Position).Unit * radius

As for facing the player upon teleportation, you can do that with a clamped CFrame.lookAt or something similar.
(Let me know if it doesn’t work, or if you need further help. untested :>)

1 Like

i tried,

upon playtesting they just teleported into the dark realm

nvm actually it was just clashing with another line of code i had it works
edit: double nvm it wasnt clashing, they’re just stuck in the middle of the baseplate

exacly what @F3vo did but shift this direction vector to the character instead of workspace origin

local AreaRadius
local Player

local Character -- character root part
local NPC -- NPC root part

-- teleport npc to the area circumference 
local Direction = (Character.Position - NPC.Position).Unit
local CircumferencePoint = Characte.Position + Direction * AreaRadius

NPC.CFrame = CFrame.new(CircumferencePoint, CircumferencePoint - Direction)
1 Like

very much works
thank you for the both of yall

ill be crediting u both in my project

thanks again

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.