#Please help!

114 messages · Page 1 of 1 (latest)

fallow owl
#

Is there a way to make a gui close automatically if another one is opened? I'm creating a menu screen and currently if a gui is open and you press another button, it will just layer over the top of the previously opened gui and you have to close it manually. I tried coding it myself but it would just bug out and make you click multiple times in order for the guis to transition. Here is my code:

local button1 = script.Parent.Parent.Parent.Parent.Photos -- Change frame names to applicable ones
local button2 = script.Parent.Parent.Parent.Parent.Teleporters
local button3 = script.Parent.Parent.Parent.Parent.Updates

-- Script --

local Button = script.Parent
local MainFrame = script.Parent.Parent.Parent.Parent.Credits

MainFrame:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Sine", .1, false)

Button.MouseButton1Click:Connect(function()
    if MainFrame.Visible == false then
        if button1.Visible or button2.Visible or button3.Visible == true then
            button1:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Back", 1, false)
            button2:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Back", 1, false)
            button3:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Back", 1, false)
            wait(1)
        end
        MainFrame.Visible = true
        MainFrame:TweenPosition(UDim2.new(0.374, 0, 0, 0), "Out", "Back", 1, false)
    else
        MainFrame:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Back", 1, false)
        wait(1)
        MainFrame.Visible = false
    end
end)
#

this section of the code is the part where i attempted to do it myself:

if button1.Visible or button2.Visible or button3.Visible == true then
            button1:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Back", 1, false)
            button2:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Back", 1, false)
            button3:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Back", 1, false)
            wait(1)
        end
tiny hawk
#

Did my script not work ؟

fallow owl
#

No the animation worked! Im just having trouble with another issue now

#

Im testing this out on one of my old game guis

#

the issue im having now is that im trying to make it so if a frame is already open, when another button is clicked it goes away

#

but the code that i made for it is kinda buggy

#

not sure why tho

tiny hawk
#

can you show me all the frames ?

fallow owl
#

yeah! one sec sorry

#

this is the code i added to this script to make already visible frames go away before the one being opened appears

#

andd let me send the video

#

if you look closely you can see it works fine the first time but the 2nd/3rd time i try to click on another button it takes a few clicks to work

minor ocean
#

Here is something I use most of the times (Im not hope so I will do it from 0 on mobile)

local guis = {} --a table with every gui you want to ge closed and opened

function openGui(x)
    for _,v in pairs(guis) do
        if v ~= x then
            v.Visible = false
       end
    end
    if x then
        x.Visible = true
    end
end

And just run the function with the variabe as first argument ( if you want to close every gui dont pass any arguments)

fallow owl
#

okay

#

would that script work with tweening?

minor ocean
#

Ofc, you could add tween and all that with a few more lines

minor ocean
fallow owl
#

kk! ill see if it works :)

#

question, is there a specific place i should insert it in my code? i just wanna make sure im doing this right

minor ocean
#

Huh... These kind of question shouldnt exit lol

fallow owl
#

also sorry im a bit confused on how to do this correctly because im a beginner at scripting

#

sorry

minor ocean
fallow owl
#

ok

#

does this look right? im sorry i dont think i understand how this works im not used to this code

tiny hawk
#

@fallow owl cnn you show me all your frames in the mune frame

fallow owl
#

okay

#

in the explorer yes?

tiny hawk
fallow owl
#

red arrows are frames im testing with and pink arrow is script

fallow owl
#

kk

tiny hawk
# fallow owl kk

try this ```lua
local ts = game:GetService("TweenService")
local button = script.Parent
local munu = button.Parent.Parent.Parent
local targFrame -- put here the frame you want to open it when you click on button and close others

button.MouseButton1Click:Connect(function()
for i , v in munu:GetChildren() do
if v ~= targFrame then
local closeTween = ts:Create(v, TweenInfo(0.5) , {Position = UDim2.fromScale()}) -- put the Position here
frameT:Play()
end
end
task.wait(0.5)
local openTween = ts:Create(targFrame, TweenInfo(0.5) , {Position = UDim2.fromScale()}) -- put the Position here
openTween:Play()
end)

fallow owl
#

ok

#

one sec

#

is this normal

tiny hawk
fallow owl
#

its okay! one sec

#

its not working :(

tiny hawk
fallow owl
#

yes one sec

tiny hawk
fallow owl
#

oh ok

#

then what do i put there

#

im confuse

tiny hawk
fallow owl
#

ok

simple islandBOT
#

studio** You are now Level 5! **studio

fallow owl
#

it still wont work :( it may be an issue with my gui or something

tiny hawk
#

can you send your gui i will scriptng it for you

#

or i ll try to make same screen and script it

tiny hawk
# fallow owl it still wont work :( it may be an issue with my gui or something

maby if you use this its will work ```lua
local ts = game:GetService("TweenService")
local button = script.Parent
local munu = button.Parent.Parent.Parent
local targFrame -- put here the frame you want to open it when you click on button and close others

button.MouseButton1Click:Connect(function()
for i , v in munu:GetChildren() do
if v.Name ~= targFrame.Nmae then
local closeTween = ts:Create(v, TweenInfo(0.5) , {Position = UDim2.fromScale()}) -- put the Position here
frameT:Play()
end
end
task.wait(0.5)
local openTween = ts:Create(targFrame, TweenInfo(0.5) , {Position = UDim2.fromScale()}) -- put the Position here
openTween:Play()
end)

#

just change the Positions and targFrame

fallow owl
#

it still doesnt work

#

its okay

#

thank u for trying

#

i really appreciate it

tiny hawk
fallow owl
#

yeah

#

howd u make it work?

#

it didnt work for me

#

and is there a way to apply a tweening style to it? (sine, back, elastic, etc)

tiny hawk
fallow owl
fallow owl
tiny hawk
fallow owl
#

can u send the updated script?

tiny hawk
#

let me to make the script work for u gui

fallow owl
#

okay

#

do u want me to publish my gui as a model and send tghe link so you can do it directly on my gui? would that be easier?

tiny hawk
fallow owl
#

okay

#

some parts are still unfinished so if it looks weird thats why

#

this is the script im working on

tiny hawk
#

@fallow owl can i delete the useless scripts ?

fallow owl
#

yes :)

tiny hawk
#

x buton --> xframe // b button --> b frame /// like this

fallow owl
#

these frames and these buttons

#

the placeholder buttons are for the "teleporters" and "updates" frames

#

u can skip those

#

so mainly just credits & photos

tiny hawk
fallow owl
#

yeah just dont do teleporters, updates, and the placeholders

#

so do these ones
Credits button ---> Credits Frame
Photos butoon ----> Photos frmae

#

sorry if i made it confusing

tiny hawk
#

try it

#

ask me if it dont work

fallow owl
#

okay one sec :)

#

nope still didnt work :( did it work for you?

tiny hawk
fallow owl
#

so it worked for you then?

#

thats so weird

tiny hawk
#

your system have broblems It prevents the GUI from working

fallow owl
#

wdym?

tiny hawk
fallow owl
#

could you possibly sceren record what it looks like when you push the buttons?

#

if it works?

tiny hawk
# fallow owl if it works?

its not work on your gui because your gui screen have scripts idk what is it do but its prevents the gui from work

#

its have alot of bugs

fallow owl
#

thats weird

#

darn it

#

oh well

#

thank you for trying

#

i appreciate it

tiny hawk
#

Maybe if you give me a detailed explanation of the purpose of the GUI i ll I will rescript it completely for you at a later time

fallow owl
#

nono its okay you dont have to do that, ill figure it out eventually

#

thank you very much though

#

i really do appreciate your help

tiny hawk