I'm a beginner to scripting and I'm trying to make a button that opens another gui when it's clicked on. It won't work and the output isn't telling me anything. What am I doing wrong?
Code:
local exitButton = script.Parent local missionGui = game.StarterGui.missionGui exitButton.MouseButton1Click:Connect(function() missionGui.ScrollingFrame.Visible = true end)
I have also tried
local exitButton = script.Parent local missionGui = game.StarterGui.missionGui exitButton.MouseButton1Click:Connect(function() missionGui.Enabled = true end)
Your miskate is game.StarterGui. I see you dont know what is the difference with PlayerGui and StarterGui. That's easy, StarterGui is the storage who duplique your UIs in the PlayerGui of the client that enter in the game.
So to modify the UI of a client you must access of her PlayerGui.
Use a LocalScript:
local PlayerService = game:GetService('Players') -- This is the folder that you can see on the explorer. local Player = PlayerService.LocalPlayer -- LocaScript only local PlayerGui = Player:WaitForChild('PlayerGui') local exitButton = script.Parent local missionGui = PlayerGui:WaitForChild('missionGui') exitButton.MouseButton1Click:Connect(function() missionGui.Enabled = true end)
Hope this help, to more questions put below in commentaries.
Starergui does not effect players you would need to edit the gui in PlayerGui. If its a localscript it's easy
local player = game.Players.LocalPlayer player.PlayerGui.missionGui.Enabled = true
In your case
local player = game.Players.LocalPlayer local exitButton = script.Parent local missionGui = player.PlayerGui.missionGui exitButton.MouseButton1Click:Connect(function() missionGui.Enabled = true end)
MUST BE A LOCAL SCRIPT
local exitButton = script.Parent local missionGui = exitButton.Parent.Parent:WaitForChild("missionGui") exitButton.MouseButton1Click:Connect(function() missionGui.ScrollingFrame.Visible = true end)
This is a bit more advanced, but it should work. I wrote it assuming that exitButton is in a gui, not a frame. It works because anything in StarterGui goes into a player's PlayerGui.