|
| 14 Jun 2014 10:31 PM |
So, this script is supposed to add points to the team with the most flags Colored the same as their TeamColor but it doesn't work properly and it just says that both sides had an equal amount even though if I taake 2 flags. Why won't it work? Oh and I though this may be important: There is not only 1 flag but 3 flags in total
for i, v in pairs (game.Workspace.Flags:GetChildren()) do local bluescore = 0 local redscore = 0 if v.BrickColor == BrickColor.new("Bright blue") then bluescore = bluescore + 1 elseif v.BrickColor == BrickColor.new("Bright red") then redscore = redscore + 1 end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
| 15 Jun 2014 01:01 AM |
what comes out when you print the brickcolor of each flag? add some prints to check what happens when, thats how i debug. |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 15 Jun 2014 01:02 AM |
Try adding this script to your flag.
script.Parent.Touched:connect(function(hit) if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then if script.Parent.BrickColor == BrickColor.new("Bright blue") then bluescore = bluescore + 1 elseif script.Parent.BrickColor == BrickColor.new("Bright red") then redscore = redscore + 1 end end end)
make sure you index "redscore" and "bluescore" to something. I suggest an outside NumberValue in leaderstats or something. |
|
|
| Report Abuse |
|
|
|
| 15 Jun 2014 01:14 AM |
| Well, I get the problem I have now so I will explain, because I have 3 flags in total, all of the flags have to be the same color and if one flag is not colored the same, it breaks. So I was now wondering, how can I change my scipt to GO THROUGH each part and check if the color is blue or red and add a point??? |
|
|
| Report Abuse |
|
|
|
| 15 Jun 2014 01:15 AM |
for i,v in pairs(workspace.model:children()) do end
loops through all chilren in the model called model in workspace |
|
|
| Report Abuse |
|
|
|
| 15 Jun 2014 01:18 AM |
| Then the problems are here: "if v.BrickColor" because it checks if all of the parts are colored the same and not just an individual part |
|
|
| Report Abuse |
|
|
|
| 15 Jun 2014 01:19 AM |
| if you just want 1 part to be checked why then no use model.part.BrickColor ? O_o |
|
|
| Report Abuse |
|
|
|
| 15 Jun 2014 01:23 AM |
| I just tested it and I was right, so I need to find a way for that loop to verify each part individually and not alltogether. |
|
|
| Report Abuse |
|
|
|
| 15 Jun 2014 01:24 AM |
| I want 3 parts to be checked... |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Jun 2014 01:25 AM |
| it does go through the parts one by one, it first checks the first one then the next one till the last one, it just does that very very fast :D |
|
|
| Report Abuse |
|
|
|
| 15 Jun 2014 01:25 AM |
Name the 3 parts other than the other parts, then do for i,v in pairs(game.Workspace.Model:children())do if v.Name=="Namehere" then --dostuff end end |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Jun 2014 01:45 AM |
| still says that they have equal score? Maybe show us the code where u compare the points. |
|
|
| Report Abuse |
|
|