Iv had help from people to try get this to work but its still failing to work in-game. My old script,
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)
Worked in studio but not in-game and I was given this script,
ImageButton6.MouseButton1Click:connect(function(onClick) local Frame = game.StarterGui.SurvivalMenu.Frame local ButtonOpen = game.StarterGui.SurvivalMenu.Open local ButtonClose = game.StarterGui.SurvivalMenu.Frame.Close ButtonOpen.MouseButton1Click:connect(function(onClick) Frame.Visible = true end) 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
ImageButton6.MouseButton1Click:Connect(function() local Player = game:GetService('Players').LocalPlayer local = Player:WaitForChild('PlayerGui') local Gui = PlayerGui:WaitForChild('SurvivalMenu') local Frame = Gui.Frame local ButtonOpen = Gui.Open local ButtonClose = Gui.Frame.Close ButtonOpen.MouseButton1Click:Connect(function() Frame.Visible = true end) end)
and for this check that:
local Player = game:GetService('Players').LocalPlayer local PlayerGui = Player:WaitForChild('PlayerGui') local Gui = PlayerGui:WaitForChild('SurvivalMenu') local TextButton = Gui.TextButton local Frame = Gui.Frame TextButton.MouseButton1Click:Connect(function() Frame.Visible = not Frame.Visible end)
So i have a little difficulty to understand ur script. I hope that I helped you, accept my answer if this working.