generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Script is not working properly

Previous Thread :: Next Thread 
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
14 Jun 2014 10:34 PM
Help please!
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
14 Jun 2014 10:36 PM
Anyone?
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
14 Jun 2014 10:40 PM
Anyone know?
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
14 Jun 2014 10:43 PM
Help!
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
15 Jun 2014 12:50 AM
Help me please!
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
15 Jun 2014 12:59 AM
Anyone?
Report Abuse
Jason27993 is not online. Jason27993
Joined: 25 Sep 2010
Total Posts: 345
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 is not online. 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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
Jason27993 is not online. Jason27993
Joined: 25 Sep 2010
Total Posts: 345
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
Jason27993 is not online. Jason27993
Joined: 25 Sep 2010
Total Posts: 345
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
15 Jun 2014 01:24 AM
I want 3 parts to be checked...
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
15 Jun 2014 01:24 AM
Possibly even more
Report Abuse
Jason27993 is not online. Jason27993
Joined: 25 Sep 2010
Total Posts: 345
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
Jason27993 is not online. Jason27993
Joined: 25 Sep 2010
Total Posts: 345
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
15 Jun 2014 01:44 AM
Still won't work...
Report Abuse
Jason27993 is not online. Jason27993
Joined: 25 Sep 2010
Total Posts: 345
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image