Hello,
I was wondering what the best way is to detect specific parts around the player using a localscript. I want to use this so multiple buttons, NPC's, events and more are easily intractable.
So far I have tried using the FindPartsInRegion3 And this was the result.
function detectNPC()
local Point1 = Character.Torso.Position
Point1 = Point1 - Vector3.new(10,10,10)
print(Point1)
local Point2 = Character.Torso.Position
Point1 = Point2 + Vector3.new(10,10,10)
print(Point2)
local Region = Region3.new(Point1,Point2)
for _,Part in pairs(game.Workspace:FindPartsInRegion3(Region,Character,math.huge)) do
print(Part.Name)
if Part.Name == "NPC" then
print("FoundNPC")
local A = Part
if A.Parent.Dialogue ~= nil then
local children = A.Parent.Dialogue:GetChildren()
end
end
end
end
while true do
wait(1)
detectNPC()
--print("tested")
end
But it detects nothing not the player or any parts around the Character. Also it gives no errors. Now two questions.
First one is this the way I should do this? (Maybe there is a better way then Findparts in Region)
And if this is the way I should do it what am I doing wrong?
