How can I make something like “print hello world when part “GoalPart” is near to player (in 2 studs).”?
you could use magnitude
to find out the distance between two parts
simply use this code:
make sure to change PART_ONE_POSITION
and PART_TWO_POSITION
to actual stuff, like hrp
local closeDistance = 2 --2 studs, change it to whatever you want
while task.wait(0.01) do --task.wait() because you dont want your code to break
local distance = (PART_ONE_POSITION - PART_TWO_POSITION).magnitude --to find out the distance between the two parts (eg: humanoidrootpart, part)
if distance <= closeDistance then --checks if they are close
print('hello world')
end
end
I havent tested it out yet, but it should work.
let me know if it works
1 Like
Thank you so much! It worked great.
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.