#im looking for a way to stop team killing in my game is there any scripts i can use?
1 messages · Page 1 of 1 (latest)
Oooh u mean friendly fire
i had it on for a while cause i coudlnt figure out how to fix it
or just check if the player who fired is in the same team as those who got hit and not deal damage
** You are now Level 3! **
nooo i got piss role
Yeah, every player has this property called team
ill explain what the game is
theres 1 team (the players)
and theres waves of npcs that charge
i got the npcs i just need the teamkilling fixing
** You are now Level 1! **
^^^
if you're not using team - search for property/attribute that they have
a
if playerA.Team == playerB.Team then return end —cancelles if same team
** You are now Level 4! **
oh
Well
i tried chat gpt but that didnt help anything
Check if the other person who you attacked is a player
You can either add a tag to all players
Or check their character every time they get hit which might be slow
would this work still for 1 team? or would it just break
local model
model:SetAttribute("Enemy",1)
---------
if model:GetAttribute("Enemy") then
--your function here
end
Since it’s NPCs it most likely won’t work
Something like this yeah
Team can only be assigned to a player
read docs
you need to learn something before calling yourself dev
i got a working game at the moment with tools that work and animations and waves that work
but im stumped at the team killing
game.Players.PlayerAdded:Connect(function(plr))
plr.CharacterAdded:ConnectFunction(char)
char:AddTag() —Enter your tag inside of the ()
end
end
Sorry for the mess
Writing this on a phone 💀
I just woke up leave me alone
i know i sound a bit needy
but
where would i put the script?
Inside of a server script, preferably one you already have to keep it organised
For example something related to the player
👍
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char:AddTag() --Enter your tag inside of the ()
end)
end)
i fixed your code
I have never used GetService for players
Like never
Ever
It’s in all of my code lol
Bad habit
what tag do i use
CollectionService
is that like the team name?
ill put player then
Also yeah thanks for adding the end) I completely forgot
it's ok
Use the new script to make sure it works
pc have syntax
Yeah lol
so now my player has a tag does it not team kill?
** You are now Level 2! **
Not really yet
You have to check inside of a script that damages the player
If it has that tag
you have to script the system
if tag then --[[action]] end
ok
simple way to explain
also check if character.Humanoid.Health > 0
also you don't really need tag inside of a player because you can
game:GetService("Players"):GetPlayerFromCharacter(otherPart.Parent)
yeah put that in your script
Yeah the reason why I think that’s going to be bad is because it will check every attack, which probably will be slow if there are 50 npcs
replace the tag
my tag is players
Alright
So
local CollectionService = game:GetService("CollectionService") —replace the " with new ones
— INSIDE OF YOUR DAMAGE FUNCTION —
if CollectionService:HasTag(Enemy, "players") then return end —again replace the " with new ones cuz apple sucks
what would i replace the collection service with?
do i replace the "players" with the name of the enemys
ifon
Epon
its white for me
is it solved yet?
** You are now Level 2! **
nope
a simple if statement will work cuh