0
votes

This is for my game. I have all the code right with no errors.

script.Parent.MouseButton1Click:Connect(function()
	game.StarterGui.ScreenGui.Enabled = true
	script.Parent.Visible = false
end)

But when I start the game the code wont work properly, only the shop button disappears which is: "script.Parent.Visible = false" and the show me the shop: "game.StarterGui.ScreenGui.Enabled = true" is not working,and wont show up the shop, yes I have the ScreenGui disabled, and there are no output errors.

2

2 Answers

0
votes

you need to make sure that you are useing the local StarterGui

when you do game.StarterGui.ScreenGui.Enabled = true you are changing the global instance and not the local. To fix this you need to use script.Parent and not game.StarterGui. Below is some example code:

script.Parent.MouseButton1Click:Connect(function()
script.Parent.%how ever many parents it takes go get back to StarterGui%.ScreenGui.Enabled = true 
script.Parent.Visible = false
end)
0
votes

In the second line, You are enabling a GUI that's located in the StarterGui not the PlayerGui, To fix the problem, Change your code to this:

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true
    script.Parent.Visible = false
end)

Also, when posting code next time, use {} button instead