Okay... I think I have a basic idea. So like you said, I will refer to the teams as Red, Blue, and Green. I will use a TeamColor (BrickColor) for the team colors.
Your script looks good so far, but in order to find the player that was killed, you need to go into the weapon bulletscript (the one that clones INTO the bullet) and add something like this:
local red = BrickColor.new("Bright red")
local blue = BrickColor.new("Bright blue")
local green = BrickColor.new("Bright green")
local bullet = script.Parent
bullet.Touched:connect(function (part)
Cash_To_Add = 5
local char = part.Parent
local playertouched = game.Players:GetPlayerFromCharacter(part.Parent.Name)
local charthatshot = script.Parent.SHOOTER.Value
local findchar = game.Workspace:findFirstChild(charthatshot)
if findchar ~= nil then
local shootingPlayer = game.Players:GetPlayerFromCharacter(findChar.Name)
local stats = shootingPlayer:findFirstChild("leaderstats")
if stats ~= nil then
local money = stats:findFirstChild("Cash")
end
if shootingPlayer.TeamColor.Name == red then
if playertouched.TeamColor.Name == blue and char.Humanoid.Health == 0 then
money.Value = money.Value + Cash_To_Add
elseif playertouched.TeamColor.Name == green
money.Value = money.Value + 0
end
elseif shootingPlayer.TeamColor.Name == blue then
end
end
end)
EDIT TO ABOVE: Fixed something: TeamColor itself is not a text value or a number value like brickcolor, so I fixed it by saying "TeamColor.Name" because that returns a text value.
Because there is that SHOOTER value on line 20 that I said you needed to make, here is the script to put into the shooter script (Like PaintballShooter in the Linked ROBLOX paintball gun)
local shooter = Instance.new("StringValue")
shooter.Value = Tool.Parent.Name
shooter.Parent = bullet
shooter.Name = "SHOOTER"
I know it is an (Time for my favorite line!) in-efficient, but working script, so I hope it works for you. Tell me if I messed up on anything!
--XanthicDragon, a fellow minor developer on ROBLOX