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: Please help with error

Previous Thread :: Next Thread 
ROBLOXHAMTAH is not online. ROBLOXHAMTAH
Joined: 08 Jul 2008
Total Posts: 9609
28 Feb 2013 06:23 PM
I made a script where when the button is clicked, the script is suppose to find all the spawns in Workspace and change their teamcolor to Bright Green.

The problem is, the script breaks if one of the spawns are not in Workspace. How can I make it check to see if any of the spawns are in Workspace, and if not, then skip to see if the next spawn in Workspace.

HEre is the script:




function finishraidspawns()

game.Workspace.RAIDBox.One.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Two.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Three.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Four.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Five.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Six.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Seven.TeamColor = BrickColor.new("Bright green")


game.Workspace.RAIDBox.Eightb.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Nineb.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Tenb.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Elevenb.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Twelveb.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Thirteenb.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Fourteenb.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Fifteenb.TeamColor = BrickColor.new("Bright green")
game.Workspace.RAIDBox.Sixteenb.TeamColor = BrickColor.new("Bright green")
end


function finishctfspawns()

game.Workspace.CTFBox.One.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Two.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Three.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Four.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Five.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Six.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Seven.TeamColor = BrickColor.new("Bright green")


game.Workspace.CTFBox.Eightb.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Nineb.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Tenb.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Elevenb.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Twelveb.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Thirteenb.TeamColor = BrickColor.new("Bright green")
game.Workspace.CTFBox.Fourteenb.TeamColor = BrickColor.new("Bright green")
end



function finishsftspawns()

game.Workspace.SFT.One.TeamColor = BrickColor.new("Bright green")
game.Workspace.SFT.Two.TeamColor = BrickColor.new("Bright green")
game.Workspace.SFT.Threeb.TeamColor = BrickColor.new("Bright green")
game.Workspace.SFT.Fourb.TeamColor = BrickColor.new("Bright green")
end

script.Parent.MouseButton1Down:connect(function()
finishraidspawns()
finishctfspawns()
finishsftspawns()

end)
Report Abuse
ROBLOXHAMTAH is not online. ROBLOXHAMTAH
Joined: 08 Jul 2008
Total Posts: 9609
02 Mar 2013 08:28 PM
bump
Report Abuse
DaneelOlivaw is not online. DaneelOlivaw
Joined: 14 Apr 2012
Total Posts: 661
02 Mar 2013 09:08 PM
I'm not terribly experienced, but you may have better luck with using FindFirstChild() for each of them, and if it returns nil then have it not do anything for that specific one.

How you have it set now is completely static: it tries to change a very specific part with a very specific place, and if one is missing then it fails, because it doesn't exist.
Report Abuse
DaneelOlivaw is not online. DaneelOlivaw
Joined: 14 Apr 2012
Total Posts: 661
02 Mar 2013 09:15 PM
function finishraidspawns()

local Workspace.RAIDBox:FindFirstChild(One) = One

if One then
One.TeamColor = BrickColor.new("Bright green")
end



That would do it for just the first spawn. Just add in that set, and add a new one for each spawn. A little bit more messy than I think some people might respond with, but that should do it.
Report Abuse
mrpricetoyou is not online. mrpricetoyou
Joined: 25 Nov 2011
Total Posts: 5160
02 Mar 2013 09:39 PM
NamesToIgnore = {"BLA", "BLA", "BLA"} -- until later on

for _, Child in pairs(game.Workspace.RaidBox:GetChildren()) do
if function() for _, ChildChild in pairs(NamesToIgnore) do if Child.name == ChildChild return false end end then
Child.BrickColor == BrickColor.new("Bright green")
end
end

Something like that...

Report Abuse
ROBLOXHAMTAH is not online. ROBLOXHAMTAH
Joined: 08 Jul 2008
Total Posts: 9609
03 Mar 2013 01:11 PM
@Daneel

I'm getting this output error:

Players.ROBLOXHAMTAH.PlayerGui.AdminPanel.Maps.RunMap:42: unexpected symbol near '.'



Here is line 42:

local Workspace.RAIDBox:FindFirstChild(One) = One
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
03 Mar 2013 02:43 PM
it may not help but.make it "one = blah blah"
Report Abuse
ROBLOXHAMTAH is not online. ROBLOXHAMTAH
Joined: 08 Jul 2008
Total Posts: 9609
03 Mar 2013 04:30 PM
bump
Report Abuse
ROBLOXHAMTAH is not online. ROBLOXHAMTAH
Joined: 08 Jul 2008
Total Posts: 9609
03 Mar 2013 06:40 PM
bump
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
03 Mar 2013 06:48 PM
pcall noob
Report Abuse
SummerOrbit is not online. SummerOrbit
Joined: 21 Nov 2012
Total Posts: 28
03 Mar 2013 07:25 PM
You could put an "if statement" for every single one. Or you could just make sure they are always in the workspace.
Report Abuse
DaneelOlivaw is not online. DaneelOlivaw
Joined: 14 Apr 2012
Total Posts: 661
03 Mar 2013 08:03 PM
I got the local backwards. Started typing it like that yesterday for some reason and made the error more than once.

It's local One = Workspace.RAIDBox:FindFirstChild(One)
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
04 Mar 2013 01:57 AM
that'swhat I said noob
Report Abuse
ROBLOXHAMTAH is not online. ROBLOXHAMTAH
Joined: 08 Jul 2008
Total Posts: 9609
04 Mar 2013 02:45 PM
@daneel

Output:

Raidbox is not a valid member of Workspace
Report Abuse
hamsterloverboy3 is not online. hamsterloverboy3
Joined: 26 Jul 2012
Total Posts: 185
04 Mar 2013 02:46 PM
Ugly code, too long, don't read.
Report Abuse
ROBLOXHAMTAH is not online. ROBLOXHAMTAH
Joined: 08 Jul 2008
Total Posts: 9609
04 Mar 2013 06:44 PM
I tried this but it says "Argument 1 missing or nil"


function finishraidspawns()

local Raidbox = Workspace:FindFirstChild(RAIDBox)

if Raidbox then

local One = Workspace.RAIDBox:FindFirstChild(One)

if One then
One.TeamColor = BrickColor.new("Bright green")
end
end

function finishctfspawns()

local ctfbox = Workspace:FindFirstChild(CTFBox)

if ctfbox then

local One = Workspace.CTFBox:FindFirstChild(One)

if One then
One.TeamColor = BrickColor.new("Bright green")
end
end
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
04 Mar 2013 07:23 PM
http://wiki.roblox.com/index.php/WaitForChild
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