.Touched not firing

What are you even trying to make in the first place?

Well, i’m making a TD game, and every time a mob would’ve touched a waypoint, it would’ve updated their “nextWaypoint” value to the next waypoint.

Well you could calculate that using time, how about that?

Some pseudo code:

speed = 10
dist = 10

task.delay(dist/speed, function()
  update_wp()
end)

Why not use Pathfinding instead?
Most people I’ve seen using mobs or tower defence type games use that instead of CFraming.

The part what the zombie needs to touch is this white brick right?

I’ve had problems using pathfinding, and i’ve found a really great module that suits my needs “BezierPath”

Yes, the zombies need to touch the big grey brick in the corner, and print that they’ve touched it.

You’re right, i could do that, but i’d resort to using time as a last option tho.

This part have CanCollide in false, the touch don’t function if CanCollide is in this value.

Maybe it’s because the gray part is in the mob’s torso. ORRRR maybe its cuz if its unanchored and cancollide is off then the part falls through the ground. Idk to be honest doesn’t make sense why it’s happening. Try either one of those though.

Nah touched events still fire if cancollide is off, if cantouch is off then it won’t.

1 Like

Can’t you just update an IntValue in the Zombie when the bezier script has to point in the new direction?

I’ve concluded a test. Apparently the .Touched event only works with physics. So the only way to do this without insane lag would be using time.

Then why does cantouch even exist.

Uhm, to turn off touch queries for physics objects?

It’s a physics thing.
If CanTouch in a Part is false then the engine never has to check to see if it’s touched.
Saves on lag in really big games.

1 Like

I thought you meant if cancollide is off the touch event doesn’t fire, nevermind.

I guess you’re right, i’ll try that.

1 Like

Try this

local connection = hb.Touched:Connect(function() end)
local results = hb:GetTouchingParts()
connection:Disconnect()
for _, v in pairs(results) do
	print(v)
end)

You could’ve just said if cancollide is off the part can still fire the touch event… you guys were confusing me for a sec.

It does fire the .Touched event but only if the part is being affected by physics.