Iv had help from people to try get this to work but its still failing to work in-game. My old script,
01 | local Button = script.Parent |
02 | Frame = script.Parent.Parent.SurvivalMenu |
03 |
04 | function onClick() |
05 | if Frame.Visible = = false then |
06 | Frame.Visible = true |
07 | elseif Frame.Visible = = true then |
08 | Frame.Visible = false |
09 | end |
10 | end |
11 |
12 | Button.MouseButton 1 Click:connect(onClick) |
Worked in studio but not in-game and I was given this script,
1 | ImageButton 6. MouseButton 1 Click:connect( function (onClick) |
2 | local Frame = game.StarterGui.SurvivalMenu.Frame |
3 | local ButtonOpen = game.StarterGui.SurvivalMenu.Open |
4 | local ButtonClose = game.StarterGui.SurvivalMenu.Frame.Close |
5 |
6 | ButtonOpen.MouseButton 1 Click:connect( function (onClick) |
7 | Frame.Visible = true |
8 | end ) |
9 | end ) |
To open the GUI, but its still not wanting to open. I have also got a script to close the GUI but its not wanting to currently work.
Any help would be appreciated, thanks.
Do you know the difference of the StarterGui and the PlayerGui?
StarterGui by ROBLOX WIKI
The StarterGui object is a service object that holds GUIs and LocalScripts. Children of this object get cloned into a Player's PlayerGui when their character spawns. If ResetPlayerGuiOnSpawn is false then the children will only be copied to PlayerGui the first time the player's character spawns.
PlayerGui by ROBLOX WIKI
The PlayerGui object is a container that holds a Player's user GUI. If a ScreenGui is a descendant of a PlayerGui, then any GuiObject inside of the ScreenGui will be drawn to the player's screen. Any LocalScript will run as soon as it is inserted into a PlayerGui. When a player first joins a game, their PlayerGui is automatically inserted into their Player object. When the player's Character spawns for the first time all of the contents of StarterGui are automatically copied into the player's PlayerGui. Note that if CharacterAutoLoads is set to false the character will not spawn and StarterGui contents will not be copied until LoadCharacter is called. If ResetPlayerGuiOnSpawn is set to true then every time the player's character respawns all of the contents of that player's PlayerGui is cleared and replaced with the contents of StarterGui.
So! Now do you understand why ur script not work? The correctly version of ur script is that:
Put this in LocalScript
01 | ImageButton 6. MouseButton 1 Click:Connect( function () |
02 | local Player = game:GetService( 'Players' ).LocalPlayer |
03 | local = Player:WaitForChild( 'PlayerGui' ) |
04 | local Gui = PlayerGui:WaitForChild( 'SurvivalMenu' ) |
05 |
06 | local Frame = Gui.Frame |
07 | local ButtonOpen = Gui.Open |
08 | local ButtonClose = Gui.Frame.Close |
09 |
10 | ButtonOpen.MouseButton 1 Click:Connect( function () |
11 | Frame.Visible = true |
12 | end ) |
13 | end ) |
and for this check that:
01 | local Player = game:GetService( 'Players' ).LocalPlayer |
02 | local PlayerGui = Player:WaitForChild( 'PlayerGui' ) |
03 | local Gui = PlayerGui:WaitForChild( 'SurvivalMenu' ) |
04 |
05 | local TextButton = Gui.TextButton |
06 | local Frame = Gui.Frame |
07 |
08 | TextButton.MouseButton 1 Click:Connect( function () |
09 | Frame.Visible = not Frame.Visible |
10 | end ) |
So i have a little difficulty to understand ur script. I hope that I helped you, accept my answer if this working.