So I have it down to this now but, I found the issue, its just not finding parts in the region even if there is; how would I fix that?
while true do
wait()
print("1")
local PNR = workspace:FindPartsInRegion3(region, hitbox, 10000)
print("2")
print(#PNR)
if #PNR < 1 then
print("no")
else
for i, part in pairs(PNR) do
print("3")
if part.Parent:FindFirstChild("Humanoid") ~= nil then
print("woah")
end
end
end
end
Could you show the full script.
local Character = script.Parent
local tradingBool = Character.trading
local hitbox = Character.PlayerHitbox
local TopLeftFrontOfPart = hitbox.Position + Vector3.new(hitbox.Size.X/2,hitbox.Size.Y/2,hitbox.Size.Z/2)
local TopRightBackOfPart = hitbox.Position + (Vector3.new(hitbox.Size.X/2,hitbox.Size.Y/2,hitbox.Size.Z/2)*-1)
local region = Region3.new(TopLeftFrontOfPart,TopRightBackOfPart)
game:GetService("RunService").Stepped:Connect(function()
--while true do
wait()
print("1")
local PNR = workspace:FindPartsInRegion3(region, hitbox, 10000)
print("2")
print(#PNR)
if #PNR < 1 then
print("no")
else
for i, part in pairs(PNR) do
print("3")
if part.Parent:FindFirstChild("Humanoid") ~= nil then
print("woah")
end
end
end
--end
end)
put the while loop outside of the Stepped event
edit: make it server sided
both of them do the same thing, there is no diffirence
Use a part for the hitbox. Region 3 hitbox is like x100 harder.Make sure to weld the hitbox to the npc. Make sure the hitbox is NOT anchored and set cancollide to false. Here’s an example file. Feel free to use it in your game.
new hitbox test for someone.rbxl (65.7 KB)
1 Like
I actually think regions don’t work in local scripts.
its not a local script and thanks for your time and effort in helping me on this, someone else just solved it
No problem, it just seems I need to get better at scripting
Region3.new(part.Position - part.Size/2, part.Position + part.Size/2)
Here’s how you make a Region3 value cover an entire part.
If the NPC is moving then you have to calculate the hit box like a million times a second. Part hitboxes are safer and easier.
It’s a hitbox? I just saw “need help with region3”, he should be using raycasts for hitboxes not region3 or GetTouchingParts().
He made a topic on how to make a Moving npc go to certain areas. He also said it was for a wandering trader. This was also for a wandering trader.
Then that would require pathfinding which itself is entirely different too.