Making a sword hurt a part based on team

Did you download the sword
You want to make NPC a team and the sword only kills the other team NPC, or you want to kill the players too

حسنًا ، أريد فريقين في لعبتي وسيكون لديهم ترسانة من الأسلحة ، ولحل هذه المشكلة سنستخدم سيفًا عاديًا. أرغب في تعيين فريق لجزء أو نموذج ، وللقيام بذلك كنت سأستخدم قيم اللون البشري والطوب لمطابقة قيم ألوان الفريق في اللعبة. إذا قام اللاعبون الموجودون في نفس الفريق الذي ينتمي إليه الجزء بضربه بالسيف ، فلن يحدث أي ضرر. إذا قام لاعب ليس من فريق الجزء بضربه ، فإن الجزء يتعرض للضرر.

Holy cow! this worked! but there are a few problems:

  • For some reason the teams are swapped but i can probably just do this myself. I can only damage the part when im on the same team, but not on the enemy team? Nevermind I fixed this

  • The hitbox is god awful

  • Will this work with explosive weapons? I wanted to have the sword coded first but it seems every weapon will have to be coded individually, any ideas?

I don’t know how the explosive weapons you use do the damage. If the damage is done by the explosion, then the way it’s done probably needs to be changed. If it’s done be directly setting health or using TakeDamage, then just adding the same checks should work.

The explosive weapons i was using are roblox’s classic ticking time bomb, and the classic rocket launcher.

A player’s sword and a player’s NPC change with the player’s team

The file contains all the details in the video
Team change sword and NPC.rbxl (40.4 KB)

Do not hesitate to ask any questions. I love to learn and help others
If there are errors, I am glad you mentioned them in the comments

1 Like