Hello Scripters! I am working on a game where you aren't supposed to kill your own teammates with your gun. However whenever I try implementing this it just breaks the whole gun. The gun I am using is in the roblox developer gun kit. I am using the AR gun from the selection. The link to the gun kit is here: Paste this into the browser top bar or else it will say blocked for some reason. https://developer.roblox.com/en-us/articles/weapons-kit So inside the AR1(Tool) > WeaponsSystem(Folder) > WeaponsSystem(Script) on line 428 there is an if then part where it then causes damage. I have tried to modify it by putting:
if target:IsA("Humanoid") and target.Team = Players then target:TakeDamage(amount) end
But it Did not work. So can you please help me how I can make it you cant damage your team mates?
Well I noticed a few bugs, such as =
not being ==
, however, I can't see where you define players. You can't just do:
if target:IsA("Humanoid") and target.Team == Players then
Because you need to first define the team and the player. So, the script should look like this:
local playerTeam = game:GetService("Teams"):WaitForChild("TheTeamNameGoesHere") local Players = game:GetService("Players") -- ^^ Put those at top of script ^^ if target:IsA("Humanoid") then local hum = target local char = hum.Parent local player = Players:GetPlayerFromCharacter(char) if player.Team ~= playerTeam then -- So basically for this line the playerTeam variable should be the team that the player is on for this to work. target:TakeDamage(amount) end end