It is not good practice to ask for entire scripts to be written for you. In order to prevent team killing, compare the teamcolor of the player dealing the damage with that of the player who is being damaged. If they are equal then do not damage the player.
Yeah isn’t a good practice i just don’t know these scripts of anti tk
It is not a matter of remembering what to write, you need to focus on understanding what the script should achieve and how it should achieve that. In my first reply I detailed what kind of things the scripts should check for, if that still is not something you can work with I recommend following the basic tutorials on the wiki to begin with.
Okay
It might help you, to look through the scripts on some weapons from the catalog, find a weapon close to what you want, test to see if it allows team killing, some do, some don’t then look at the script and see how they disable it. TaaRt is correct, all they really do is compare the team color of the ‘target’ with the team color of the player who created the projectile, or who is the owner of the weapon, and if they are the same, it exits the damage function.
Simply put, have a condition in the weapon which checks the team color of the target, and if the target is in the same team with the shooter(or attacker), ignore other lines, such as damage.
I’ll give you and idea of how
if Player.Team ~= TargetPlayer.Team then
-- Do Damge to the TargetPlayer
end
There, Some people learn better when they see a script, one of them is me.
Once you got your Solution make sure you mark it as Solved.
just some useful links:
I know I’m somewhat repeating what the above have said, but there isn’t really such a thing as an anti-teamkill script. It would be near impossible to create an anti-TK script that can just be dropped into a game and work, you have to code the anti-TK functionality into the weapons you are using.
I’m gonna repeat what other people have said, but I’ll also provide a good solution. There is no such thing as an Anti Team Killing script. Instead, you need to check the teams of two player before damaging them; a good practice is to have one universal function for damaging players in the server script.
In server script:
local function dmgPlayer(plr, targetPlr, dmg)
if plr.Team ~= targetPlr.Team then
targetPlr.Character.Humanoid:TakeDamage(dmg)
end
end
DmgRemote.OnServerEvent:Connect(dmgPlayer)
In the client, you can just call this remote event to damage another player. This is self explanatory, so I’m not going to write that out. It also depends on what kind of weapons/tools you are using.
Having a universal damage player function is better because you can also add damage multipliers in the universal function, award points, check if a player has killed another player for a death log, etc.
[EDIT]
You can also add these checks on the client too before it fires the damage player or tool event. This will lessen the remote calls, and it is still secure because it checks on the server as well.
if targetPlayer.Neutral or player.Neutral or targetPlayer.Team ~= player.Team then
-- deal dat damage
end
Oh okay, yeah putting some anti tk scripts in the gears? because some gears like Sword before didn’t have some scripts about team kill disable and etc. the actual Classic Sword have some configurations but i mean how to put these anti tk scripts in a gear for the team? is really necesary a option in the property of teams that option could be Team Kill Allowed: No or Yes etc etc
If anyone remember Heli Wars: Desert Attack and if he played that game well in there you will understand what i am saying in that game people sometimes kill each others being teammates i really hate that but the only anti tk that they had is to kill the killer when you can also get the wo and ko. is really necessary a option from the team property to change if it’s to kill each other being teammates or isn’t allowed to kill each other being teammates
Open up the scripts of whatever tool it is. Find where it deals the damage. You can use Ctrl+F in a script to search. I’d suggest searching for
:TakeDamage(
or
.Health
When you’ve found the spot where one player is taking damage, you will want to put that check that people have supplied on this thread before dealing the damage. You may need to make some variables for the targetPlayer or player.
Ok i will try
I believe the ‘blow’ function inside SwordScript should be where you put the section of code. As I think it’ll return hit (which should be player).
It should be under the blow section as @FernandoMacLeod had stated. And rather then searching all of that you should need to just search TakeDamage.
if Player.TeamColor ~= player.TeamColor then
humanoid:TakeDamage(Damage)
end
i can also put this local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player.TeamColor ~= vPlayer.TeamColor then
tagHumanoid(humanoid, vPlayer)
humanoid:TakeDamage(damage)
wait(1)
untagHumanoid(humanoid)
end or idk