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:
01 | local red = BrickColor.new( "Bright red" ) |
02 | local blue = BrickColor.new( "Bright blue" ) |
03 | local green = BrickColor.new( "Bright green" ) |
05 | local bullet = script.Parent |
07 | bullet.Touched:connect( function (part) |
11 | local char = part.Parent |
13 | local playertouched = game.Players:GetPlayerFromCharacter(part.Parent.Name) |
17 | local charthatshot = script.Parent.SHOOTER.Value |
18 | local findchar = game.Workspace:findFirstChild(charthatshot) |
20 | if findchar ~ = nil then |
21 | local shootingPlayer = game.Players:GetPlayerFromCharacter(findChar.Name) |
22 | local stats = shootingPlayer:findFirstChild( "leaderstats" ) |
24 | local money = stats:findFirstChild( "Cash" ) |
26 | if shootingPlayer.TeamColor.Name = = red then |
27 | if playertouched.TeamColor.Name = = blue and char.Humanoid.Health = = 0 then |
28 | money.Value = money.Value + Cash_To_Add |
29 | elseif playertouched.TeamColor.Name = = green |
30 | money.Value = money.Value + 0 |
32 | elseif shootingPlayer.TeamColor.Name = = blue then |
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)
3 | local shooter = Instance.new( "StringValue" ) |
4 | shooter.Value = Tool.Parent.Name |
6 | 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