#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)

charred ivy
#

any help please

late thorn
#

Oooh u mean friendly fire

slow trail
#

keep the chaos

#

kick people who kill teammates

charred ivy
#

i had it on for a while cause i coudlnt figure out how to fix it

slow trail
#

or just check if the player who fired is in the same team as those who got hit and not deal damage

magic garnetBOT
#

studio** You are now Level 3! **studio

slow trail
#

nooo i got piss role

charred ivy
#

well the thing is
Im quite bad at coding

#

and i dont know how to code this

vagrant adder
#

Yeah, every player has this property called team

charred ivy
#

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

magic garnetBOT
#

studio** You are now Level 1! **studio

slow trail
vagrant adder
#
if playerA.Team == playerB.Team then return end —cancelles if same team
magic garnetBOT
#

studio** You are now Level 4! **studio

charred ivy
#

i tried chat gpt but that didnt help anything

vagrant adder
#

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

charred ivy
slow trail
vagrant adder
slow trail
#

read docs

charred ivy
#

i was just asking

#

im quite new to making games

slow trail
#

you need to learn something before calling yourself dev

charred ivy
#

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

vagrant adder
#
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 💀

slow trail
#

faker

vagrant adder
charred ivy
#

i know i sound a bit needy
but
where would i put the script?

vagrant adder
#

For example something related to the player

charred ivy
#

👍

slow trail
#
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

vagrant adder
#

Like never

#

Ever

#

It’s in all of my code lol

#

Bad habit

charred ivy
#

what tag do i use

slow trail
#

CollectionService

charred ivy
#

is that like the team name?

vagrant adder
#

Anything you want

#

Like “Player”

charred ivy
#

ill put player then

slow trail
vagrant adder
vagrant adder
slow trail
#

pc have syntax

vagrant adder
#

Yeah lol

charred ivy
#

so now my player has a tag does it not team kill?

magic garnetBOT
#

studio** You are now Level 2! **studio

vagrant adder
#

Not really yet

#

You have to check inside of a script that damages the player

#

If it has that tag

slow trail
#

if tag then --[[action]] end

charred ivy
#

ok

slow trail
#

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)
charred ivy
#

do i put that into my script?

#

or is that an example

slow trail
#

yeah put that in your script

vagrant adder
slow trail
#

replace the tag

charred ivy
#

my tag is players

vagrant adder
#

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

charred ivy
#

what would i replace the collection service with?

#

do i replace the "players" with the name of the enemys

vagrant adder
#

No

#

It’s just the "

#

Because on mobile Roblox studio don’t like them

slow trail
#

you're using wrong dash my guy

vagrant adder
#

Same bs there

#

I just can’t code on mobile

#

Wrong emoji 😭

slow trail
vagrant adder
slow trail
#

ifon

vagrant adder
#

Epon

charred ivy
#

its white for me

vagrant adder
#

Man I love my Wi-Fi

#

Now the images are loaded los

fading imp
#

is it solved yet?

magic garnetBOT
#

studio** You are now Level 2! **studio

charred ivy
fading imp
#

a simple if statement will work cuh