Hello, I am trying to make a script which finds a number of how many models are touching a part. The model is NPC and it has same name as other NPCS there is ussualy alot of them.
How it looks outside script:
How it should look like:
Inside of the script:
local part = script.Parent
local TopLeftFrontOfPart = part.Position - (0.5 * part.Size)
local TopRightBackOfPart = part.Position + (0.5 * part.Size)
local region = Region3.new(TopLeftFrontOfPart,TopRightBackOfPart)
local count = 0
script.Parent.Touched:Connect(function()
for _,Part in pairs(game.Workspace:FindPartsInRegion3(region,nil,math.huge)) do
if Part.Parent.Name == "Dummy" then
count = count + 1
script.Parent.Parent.MainS.SurfaceGui.TextLabel.Text = count
end
end
print(count)
count = 0
end)
Hope you can solve my problem.