Yeah so basically to put it simply if cancollide is off the touched event still happens. JUST BE MORE SIMPLE BRO.
This only prints the current touching parts at the moment of execution…
It will print all the parts that are colliding, so if you want only that specific part to be detected, use end)
Adding onto what @6Communist_Wolf9 said you can filter out the parts you want by looping through the parts and using an if statement to check if they meet a condition that you want it to.
Use a loop in this case.
while wait(0.1) do
local connection = hb.Touched:Connect(function() end)
local results = hb:GetTouchingParts()
connection:Disconnect()
for _, v in pairs(results) do
print(v)
end)
end```
That isn’t the problem, it’s that when the code sent by communist wolf is ran, it will print the current colliding parts, and running 50+ loops is not very efficient…
So make the part you want collideable, and place it so that it doesn’t interfere with the dolls’ progress. There is an example: (The red part is the part what the doll needs to touch)
Touch events need physics to work, there is no physics involved in my problem
Why you need this collision? Por que razão?
Improve your programming and use a distance check from the tower instead. Drop this pointless discussion.
Are you saying to loop through the folder of mobs and check each mob’s position to the grey part and check if it’s passed, multiple times, because my map has more waypoints? Wouldn’t that hurt the performance?
No. Redo your whole system, the NPCs aren’t supposed to do anything except pathing, animating, etc.
The towers themselves do a distance check.
Okay, i get now what you mean.
But if i do a distance check from the tower to the mob, then it’ll target the closest mob to the tower, but what i want is for the towers to attack the closest enemy to the end. (aka, the next waypoint)
You need a percentage based on how far the npc has traveled the path rather than an actual position based distance system if you want that.
Okay, that’s a good idea, thank you!
see if this works.
also it seems like you are putting this script inside the zombies torso?
mob.Part.Touched:Connect(function(part)
print("ran")
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.