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

How can i get the location of a npc?

Asked by 6 years ago

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?

0
You need to have at least tried a few scripts before asking the question. We won't script your game for you. Viking359 161 — 6y
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.. Icezown 4 — 6y
0
use clamp() to get vectoral region and then make sure if the player is there, a function will happen greatneil80 2647 — 6y
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++ Icezown 4 — 6y
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. chess123mate 5873 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

Ad

Answer this question