Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I stop players from killing their own teammates with the AR roblox kit gun?

Asked by 3 years ago
Edited by Leamir 3 years ago

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?

0
Please include more to your script, what it "Players?" NickIsANuke 217 — 3y
0
Link fixed Leamir 3138 — 3y
0
thanks epicnmac 63 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

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
Ad

Answer this question