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

How can i get the location of a npc?

I have a character that moves to a postion. How do i check that he is at that postion to have him do something once he is there?

5 comments

0

You need to have at least tried a few scripts before asking the question. We won't script your game for you.

0

All im asking for the terms roblox uses. i have knowledge of scripting (i use UE4) but the terms are different with them. For Ue4 i just have to type getactorlocation im not sure what it is for studio thats all i want to know..

0

use clamp() to get vectoral region and then make sure if the player is there, a function will happen

1

Ok, Isnt a clamp used to keep values within a range so they dont go under or over what you want them to? Atleast thats what it does is C++

0

@Icezown: you are correct. "math.clamp(number, 0, 5)" returns a value between 0 and 5 that is as close to 'number' as possible.

1 answer

You need to check the distance between the NPC (ex his Torso/HumanoidRootPart/whatever) and the target point with (part1.Position - part2.Position).magnitude. There is no event for this, so you will have to use a while loop to keep waiting until the magnitude is less than some value.

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