So basically im trying to make a projectile explode when hitting enemies, but the hitbox is just not detecting them, for context im using tween to move the projectile
here’s the part of my code that’s responsible for checking the touch event
local c
c = lanza.Hitbox.Touched:Connect(function(hit)
print(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= char then
stop = true
tween:Pause()
c:Disconnect()
end
end)
As a tip you shouldn’t be using touched events for hitboxes. Since the detection rate is kinda bad, especially in a live game where there’s gonna be tons of lag alot of touches won’t register.
Use spatial queries instead, you can use getpartsboundsinbox for example. Or maybe raycasts.
I think that the touched event itself may actually be the problem, since touched events have bad detection. Especially when you have an object movijng super fast like in your video, thats why it probavly doesnt register.
Eh, not that much. But, you don’t even need to loop. You can just use the hit detection when the player does the action. It’s like a click to shoot right? Just use an event.
You may need to use a temporary loop though actually.
Besides it’s not like its detecting a huge amount of stuff anyway, it’s quite a small box from what I can see. So it probably wouldn’t be too heavy on performance.
Actually yeah I think thats the problem since in the video the box just goes straight through the enemies. But that might just be because its a big box and its moving fast.
the “plr” variable is the Player, i get it from a local script that detects tool activation, that sends a remote event to another script that only then calls this module
local c
c = lanza.Hitbox.Touched:Connect(function(hit)
local Character = hit.Parent
local IsModel = Character:IsA("Model")
local Hum = Character:FindFirstChildOfClass("Humanoid")
if Character and IsModel and Hum and Character ~= char then
stop = true
tween:Pause()
c:Disconnect()
end
end)