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: Can't Tween GUI's that aren't in Workspace error...

Previous Thread :: Next Thread 
Veltamax is not online. Veltamax
Joined: 06 May 2012
Total Posts: 368
03 Jun 2014 10:28 AM
I am not understanding why this doesn't work. I want this textbutton, when I click it, to create the frame and move it to the top, and when I click it again, to move back to the bottom, and remove the frame, and to be able to be done as many times as I want. When I test, it will open it and do what I want, but after the frame removes, and I click it again, it says "Can only tween objects in the workspace". My fail-safes are doing the opposite effect... Could someone see what I'm doing wrong?

Code:

script.Parent.MouseButton1Down:connect(function()

if startframe == nil then

startframe = Instance.new([[Frame]], script.Parent.Parent)
--startframe properties (took out to shorten post)

startframe:TweenPosition(UDim2.new(0,0,0,20), [[Out]], [[Back]], .5)

elseif startframe ~= nil then
--V ERROR V (even though it only should get here if startframe isn't nil)
startframe:TweenPosition(UDim2.new(0,0,0,320), [[In]], [[Back]], .5)
wait(2)
startframe:remove()
end
end)
Report Abuse
Veltamax is not online. Veltamax
Joined: 06 May 2012
Total Posts: 368
03 Jun 2014 10:37 AM
Bumpity-bump.
Report Abuse
GeneralUserInterface is not online. GeneralUserInterface
Joined: 25 May 2011
Total Posts: 26
03 Jun 2014 10:39 AM
Is this the whole script?
Have you put the startframe variable at the start of the script?
If not, then that's the problem, the if and the else are separated.
If you created startframe under the "If", then it's only available in "If", the same thing for the "Else".

idk. I hope it helps even just one bit.

Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
03 Jun 2014 10:42 AM
The remove method simply changes the parent property of startframe to nil, but if you made a reference to it before removing it, it will still exist.

local Frame = Instance.new("Frame", nil)
print(Frame == nil) --> false

local Frame
print(Frame == nil) --> true

You'd be better off, in my opinion, using FindFirstChild to see if the frame existed or not.
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