Hey! I was making some UI stuff for my game, and I wanted to make a text button, and when the textbutton is clicked, make visible a frame and then clicking again, make invisible back again the frame.
I wrote one code but isn’t working, here it is:
local button = script.Parent.TextButton
local frame = script.Parent.Frame
local function toggleFrame()
if frame.Visible == true then
frame.Visible = false
else
frame.Visible = true
end
end
button.MouseButton1Click:Connect(toggleFrame)
It would be really helpful if someone can re-make my code if there are any issues with it or make a new one and reply here, thanks!
Uhm, looking at your script you have to define what exactly you want to change like
local button = script.Parent.TextButton
Doesn’t exist, there is only play, shop and updates (according to your naming of the TextButton). You have to exactly pin point what text button it is, same thing goes for
local frame = script.Parent.Frame
I am not really sure if you the Child of ScreenGui or the other two, but yeah
Also I don’t see a localscript in here, is the script in a TextButton or Frame? (you should also maybe show where the local script is)
Hey! So the UI is located there as it is a baseplate for only the game main menu, as there are many options such as buy on the shop, check lastest updates, or just be teleported to game.
Hey! So I made changes on script following suggestions from some answers, here is how script looks like & explorer too:
local button = game.StarterGui.ScreenGui.Frame.shop
local frame = script.Parent.Frame.Tienda
local function toggleFrame()
if frame.Visible == true then
frame.Visible = false
else
frame.Visible = true
end
end
button.MouseButton1Click:Connect(toggleFrame)
Explorer screenshot:
Here “Local Script” it’s actually where’s located at the script inside the screen gui, and then the frame that I need to code for the button is shop. It’s still not working so i’ll really appreciate any help.
Now knowing what you want to change: Here this will work! (i hope)
local button = script.Parent.Frame.shop
local frame = script.Parent.Frame.Tienda
local function toggleFrame()
if frame.Visible == true then
frame.Visible = false
else
frame.Visible = true
end
end
button.MouseButton1Click:Connect(toggleFrame)