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 » Scripters
Home Search
 

Re: Broken GUIs - Please help!

Previous Thread :: Next Thread 
Busterkiki01 is not online. Busterkiki01
Joined: 17 Jul 2012
Total Posts: 61
15 Feb 2016 04:06 PM
Hey, so I'm working on this game that has a GUI where you equip weapons using buttons. Every button has a script inside of it that looks like this:

local target = script.Parent.Parent.Parent:FindFirstChild("TextButton") --[[locates "Play" button ]]--

local weapon = target:FindFirstChild("goal") --finds the string value I need to change

function onClicked(GUI)
weapon.Value = "Axe" -- changes the value
end


script.Parent.MouseButton1Click:connect(onClicked) -- runs the above function on click

So far, this is perfect in Studio, but the second I test it in real roblox, nothing works. The problem is with line 2, it say "target" is a nil value?

I was wondering if someone could figure out what's wrong, it's driving me crazy.

BTW, this is in a local script, so...
Report Abuse
cheesecake123456 is not online. cheesecake123456
Joined: 01 Jun 2009
Total Posts: 1529
15 Feb 2016 04:09 PM
Try putting this at the start:

repeat wait() until script.Parent.Parent.Parent:FindFirstChild('TextButton')


Report Abuse
Busterkiki01 is not online. Busterkiki01
Joined: 17 Jul 2012
Total Posts: 61
15 Feb 2016 04:12 PM
Ok, that seems to have fixed it, thanks!

So I'm assuming it was a problem with the loading process?
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
15 Feb 2016 04:14 PM
WaitForChild

http://wiki.roblox.com/index.php?title=API:Class/Instance/WaitForChild
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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