My friend and I have a projectile that is fired to the cursor location on a key press but when the orb passes through yourself it does not do damage to the enemy on the other side
COMMUNITY QUESTION
How do I have a projectile pass through players and still do damage to NPC humanoids?
1 answer
Assuming quite heavily that your orb works a lot like the rocket launchers in Roblox, here's your fix. To let your "orb" pass through players, I recommend that you change the collision group and only allow the "enemy" collision group to be able to collide with the "orb."
Here's a link to a useful tutorial on using collision groups: https://www.robloxdev.com/api-reference/class/PhysicsService
Also, on the script side of things, I would recommend you to use an "if" statement to check whether it collided with a player or an enemy. Here's a sample:
orb = script.Parent
orb.hit:Connect(function(WhateverItHit)
if WhateverItHit:FindFirstChild("Humanoid") then
--I guess you could leave this blank or set it to "if not WhateverItHit ... then..." and you will be able to not require to put in an elseif statement.
elseif WhateverItHit:FindFirstChild("Enemy") then
--The "Enemy" can just be the NPC "Humanoid" renamed to "Enemy".
end
end)
If you have any questions or issues, please contact me. ;)
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
script pls
Add a conditional statement to your script that checks if they're NPC, if it is, do damage. If it's not, don't deal the damage
how does the projectile move?, by BodyMovers, CFrames or its just a Raycast