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 » Game Design
Home Search
 

Re: Function not behaving the way it should

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
15 May 2016 03:26 PM
local MUI = Guis["Menu_UI"]:Clone()
MUI.Parent = Plr.PlayerGui

local Res = MUI.Research
local Pro = MUI.Profile
local ToB = MUI["Top Border"]
local BoB = MUI["Bottom Border"]

local Book = Res.Book

local ImgBtn = Book:GetChildren()
for i = 1, #ImgBtn do if ImgBtn[i].ClassName == "ImageButton" then
ImgBtn[i].MouseButton1Click:connect(function()
for o = 1, #ImgBtn do if ImgBtn[o].ClassName == "Frame" then ImgBtn[o].Visible = false
ImgBtn[i]:TweenSize(UDim2.new(0, -50, 0, 42), "Out", "Linear", 0.25, true)
end end
ImgBtn[i]:TweenSize(UDim2.new(0, -100, 0, 42), "Out", "Linear", 0.25, true)
Book[ImgBtn[i].Name].Visible = true end) end end



I'm not getting any errors, the function just isn't doing what it's supposed to do.
It's SUPPOSED to make all of the ImageButtons shrink down and set frame visibility to false before growing the ImageButton that was clicked on to full size and setting the visibility of the associated frame to true.

To me the function looks fine but obviously I'm doing something wrong.

As of right now, the frame behavior is fine, but the size tweening is not.
On one hand when testing it, only the button I click on grows, but none of them shrink
but if I set the tween override bool to false, they shrink when clicked but do not grow.

It's confusing, infuriating, aggravating, and quite frankly I'm on the verge of tears.

You have to understand I've been working on this game since 2010 and after a couple version of it I've finally come up with a design that actually works and now I'm getting stuck constantly. I'm at my limit and I don't know how much more I can take...
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
15 May 2016 07:18 PM
bump
Report Abuse
ColonySimulator is not online. ColonySimulator
Joined: 05 Jul 2015
Total Posts: 1721
15 May 2016 08:17 PM
Wrong subforum , but I think I figured why your function isnt working!

So first let see your code.
So as we can see you are trying to get all the children of a parent list and you set them as object in your :GetChildren() method and then you use the for loop to find all the good Button in the list. Then you set an event that if we click on any of these button that match the good event it will work. The problem is that a for loop will execute only once. So you should put it in a while loop!

By the way you should declare each time in the while loop your list (:GetChildren()) because the while will reset and go.

while wait() do
-- your code here
end
Report Abuse
ColonySimulator is not online. ColonySimulator
Joined: 05 Jul 2015
Total Posts: 1721
15 May 2016 08:18 PM
So it should look like this. I hope it worked.

local MUI = Guis["Menu_UI"]:Clone()
MUI.Parent = Plr.PlayerGui

local Res = MUI.Research
local Pro = MUI.Profile
local ToB = MUI["Top Border"]
local BoB = MUI["Bottom Border"]

local Book = Res.Book

while wait() do
local ImgBtn = Book:GetChildren()
for i = 1, #ImgBtn do if ImgBtn[i].ClassName == "ImageButton" then
ImgBtn[i].MouseButton1Click:connect(function()
for o = 1, #ImgBtn do if ImgBtn[o].ClassName == "Frame" then ImgBtn[o].Visible = false
ImgBtn[i]:TweenSize(UDim2.new(0, -50, 0, 42), "Out", "Linear", 0.25, true)
end end
ImgBtn[i]:TweenSize(UDim2.new(0, -100, 0, 42), "Out", "Linear", 0.25, true)
Book[ImgBtn[i].Name].Visible = true end) end end
end
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
15 May 2016 09:33 PM
It's not that I don't appreciate the help, but I've used my method before but not with tweening.

The original :GetChildren() method tags all of the items in the parent, and the if statement right afterwards "detects" which ones I'm actually looking for, and by then I use the function to connect when they've been clicked on.
After they've been clicked, I use another for loop to make them all invisible and shrunken, and then after that for loop is ended I go ahead and grow back out the button that was clicked and make visible the frame that's associated with it.

Like I said I've done it this way many many MANY times before and it's always worked flawlessly, but the tweening just won't work properly for some reason.

As I stated in my original post, the frame visibility works perfectly, as does which frame is associated with which button. That part of this script works flawlessly, but as you can also see I placed the second tweening BEFORE making the associated frame visible again. So there's something about the tweening itself that simply isn't working properly with the function.

I guess I can skip the tweening and just set the sizes manually. It won't hurt the game, I just wanted a nice little animation to go with the thing.

I'll try it that way and let you know how it went
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
15 May 2016 10:00 PM
Looks like I got it fixed


local MUI = Guis["Menu_UI"]:Clone()
MUI.Parent = Plr.PlayerGui

local Res = MUI.Research
local Pro = MUI.Profile
local ToB = MUI["Top Border"]
local BoB = MUI["Bottom Border"]

local Book = Res.Book

local ImgBtn = Book:GetChildren()
for i = 1, #ImgBtn do if ImgBtn[i].ClassName == "ImageButton" then
ImgBtn[i].MouseButton1Click:connect(function(Button)

local Btns = Book:GetChildren()
for o = 1, #Btns do
if Btns[o].ClassName == "Frame" then Btns[o].Visible = false
elseif Btns[o].ClassName == "ImageButton" then Btns[o].Size = UDim2.new(0, -50, 0, 42)
end end

ImgBtn[i].Size = UDim2.new(0, -100, 0, 42)
Book[ImgBtn[i].Name].Visible = true end) end end


Not sure why it was misbehaving this time, but it was not the tweening after all. Strange though, I've done the same thing before and it worked just fine
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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