Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My screen gui wont open the frame what happened?

Asked by 6 years ago

I have a ScreenGui with a frame in it. I have image buttons inside it with a local script with this in

local Button = script.Parent
Frame = script.Parent.Parent.SurvivalMenu

function onClick()
if Frame.Visible == false then
Frame.Visible = true
elseif Frame.Visible == true then
Frame.Visible = false
end
end

Button.MouseButton1Click:connect(onClick)

In Studio it opens the SurvivalMenu but then in-game it doesn't work. Any ideas why?

If you know why please tell me and I will try, Thanks :)

0
You probably use a serverscript, you should use a local script User#20388 0 — 6y
0
i have a local in my imagebutton which has that code but it won't work in-game and im not sure why, thanks for the help though bubyspp1 5 — 6y
0
I updated my description but if you don't want to make this many scirpts use your current one and put it inside a local script. But I recommend making 2 scirpt one to open the gui and one to close it :) Lualaxy 78 — 6y

1 answer

Log in to vote
0
Answered by
Lualaxy 78
6 years ago
Edited 6 years ago

It depends what you need it for one is for each player then use a local script and enter

Button.MouseButton1Click:connect(function(onClick) 
-- You don't even need the onClick, depends what this is for :)
-- Enter functions here
end)

But if the survivial menu is going to change depending on players options for all players then use events. You probably should also make 1 button open the frame and in that frame there is a button to close the frame. If you need code that is complete or you have any questions or even want to correct me then feel free to do so :)

Edited:

Well. As I said it really depends what you need the GUI for. As I understand survival menu won't change any values/text depending on players right? (correct me if im wrong) so all you need to do is make a button, a frame for the survival menu, in the survival menu/frame make another button. Now inside the first button which will open up your GUI/Survivalmenu/Frame put the script I put in my answer. Inside the function I wrote for you make something like this:

-- First we need to tell the game what is what. For example:

local Frame = game.StarterGui.SurvivalMenu.Frame

local ButtonOpen = game.StarterGui.SurvivalMenu.Open 
 -- So this is the button that will open GUI

local ButtonClose = game.StarterGui.SurvivalMenu.Frame.Close
-- This is the button that is inside the frame that will only show if you press the open button
-- Thats why its inside the frame and the first button isn't

-- Next thing we need to do is make a function that will open the GUI for the player.
-- I recommend a localscript for now so we can use the LocalPlayer function
-- We will use local player because the gui is going to be the same all the time.
-- If I undestood this Survival Menu wrong tell me and I'll fix the script.

-- This first scirpt needs to be in the open button, which needs to be visible.
-- The frame and the close button needs to be hidden.

ButtonOpen.MouseButton1Click:connect(function(onClick) 
-- First thing we need to do in here is write what will happen if the player clicks the button.
      Frame.Visible = true
-- When the Frame/SurvivalMenu will become visible it will show text and stuff that you put in.

-- Also the button to close the gui will also be showing so if you put the close button inside
-- the frame you don't need to hide the close button since only hiding the frame will do.
-- I think that this is all we need to enable the gui.

end)

Now you got the open button working. Now we need a scirpt that will close is. The close button is in the frame that is showing if we click the first button the OpenButton.

The following code needs to be inside the close button.

ButtonClose.MouseButton1Click:connect(function(onClick) 
       Frame.Visible = false
end)

I beleve thats all we need for the frame/survival menu to show. If I understood the usage of the SurvivalMenu wrong or I described the function to complicated tell me and I'll fix all of this and do it in a more simple way :) [If anyone wants to correct me feel free to do so since I make mistakes sometimes :P]

0
i tried your script but sadly it didnt work, what part of my script would i put inside for the function (im so bad with functions, srry) bubyspp1 5 — 6y
0
UPDATED THE SCIRPTS AND DESCRIPTIONS Lualaxy 78 — 6y
Ad

Answer this question