Alternative method for this?

I have projectiles that the player shoots from their hand. Currently I’m making the projectiles part of the player’s character so that I can know what player not to do damage to (for example, if the projectile spawns in the location of the player, if the player touches the projectile, it won’t do damage. I do this by using :IsDescendantOf() and :GetPlayerFromCharacter())
However, this means that with the way I’ve scripted the game, if another player hits the projectile you shot, it will do damage to you. It also means it triggers touched events from the player.
What is an alternative that will accomplish what I want (being able to know what player fired the projectile and not hurt them)?

Can’t like you said use :IsDescendantOf() and :GetPlayerFromCharacter()) and then use an if statement to view if the user who fired the projectile == to the name of the thing it touched (in this case the character)

…yes
…thats what im doing
the problem is thats not a good way of doing it because if another player hits the projectile it will hurt the the guy who shot it
which isnt how projectiles are supposed to work
hence why im looking for an alternative

But your issue makes 0 sense. If you code it like I said you should be able to filter out using an if statement. All you have to do is say if the character that the projectile hit is not the user who fired it cause damage to that user.

It sounds more like your main code for it is incorrect cuz I really don’t see why you are having an issue.

dude
youre missing the point

look
lets say i have player 1
and player 2
player 2 hits player 1 in the arm
thats gonna cause damage to player 1 right? yes, because the arm is part of his character

its the same issue
when i put the projectile in the players character (with the method i am using), it acts the same way
the projectile now acts as the players character
this means
-if another player were to shoot the projectile, or hit it with a sword, the player who shot the projectile takes damage
-the projectile is able to trigger touched events

Would it be possible for you to send the code. I still think what ur saying does not make sense at all.

dude what part of this do you not understand

All you have to do is once the projectile is fired get what ever it touches. If it is a character check what character it was that was touched. You then get that character and cause the damage to that character that it touched. Before you cause damage however check to see if the character it touched is not the character which fired it.

I don’t get the issue? Legit it is that simple.

dude
thats
not
the
issue
the issue
is if a different player hits the projectile
not
with their BODY
but with a WEAPON
because the projectile is part of the player’s CHARACTER
it acts as a body part
meaning if a different player ATTACKS SAID PROJECTILE
it acts as if the player was attacking the player itself
meaning the player who shot the projectile takes damage
does that make sense now

Okay, so I understand what’s happening. When something hits the projectile that a player shot, it’s detecting if it’s a part of the character, so it’s dealing damage to who shot it. You can try making a folder of “Projectiles” in the character and having them filtered out from the search, maybe?

GOD THANK YOU
YOU UNDERSTAND LOL

So, I’m using :GetDescendants() to detect all the parts of the player, I believe, that or :GetChildren(). In that case, should I do something like

local parts = :GetDescendants()
for i v in pairs(parts)
if part.classname = part and not part:isdecendantof(nameoffolder) then

also i know thats bad coding its just cuz i didnt feel like making it perfect and rather just wanted to communicate the idea

Yeah, that’s what I’m thinking, so pretty much checking if it is a descendant of the character itself, but if it isn’t a descendant of the filtered folder.

Wait new idea
What if instead I make a folder in workspace called “Projectiles” and then have a folder for every player inside it (with the same name as the player) and then put them in there
then I can say if hit.Parent.Name ~= script.Parent.Name then?

or something like

if hit.Parent:FindFirstChild("Humanoid") and not script:IsDescendantOf(hit.Parent.Name)

That should work, although a lot of games will have a tag or variable on the projectile itself which helps with rewarding the player who hit the enemy.

Well couldn’t I just (after I’ve confirmed it’s a humanoid and dealt damage to it) say:
“if hit.Parent.Humanoid.Health <= 0 then” and then reward the play by using game.Players:FindFirstChild(projectilefolder.name)

Yeah, you could. I was just saying you can do it the way with variables. Your idea may be more efficient though,

Alright, thanks a ton for the help!