script.Parent.Touched:connect(function() if game.StarterGui.Shop.Background.Visible == false then game.StarterGui.Shop.Background.Visible = true end end) --It's pretty simple, when someone clicks the brick, the background of a shopgui becomes visible. what's broken?
You said when they click the brick. In this situation you need a Clickdetector! Insert a click detector in the part. The code should be like this
The Function Is A OnClicked, Not An OnTouched
It Is Also Easier to Define and Could Make It More efficent
Background = game.StarterGui.Shop.Background function onClicked(mouse) if Background.visible == false then Background.Visible = true end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
I Hope This Helped You!
script.Parent.ClickDetector.MouseClick:connect(function(plr) local player = game.Players:WaitForChild(plr.Name) local gui = player.PlayerGui if gui.Shop.Background.Visible == false then gui.Shop.Background.Visible = true else gui.Shop.Background.Visible = false end end)
This problem is quite simple! You are accessing the StarterGui which is not what you want for live events. Instead you need the PlayerGui. This can be accomplished using the :GetPlayerFromCharacter() method
script.Parent.Touched:connect(function(hit)--Hit is what touches the part. if game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.Shop.Background.Visible = false--we get the Player from game.Players then game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.Shop.Background.Visible = true end end)
That should be it! Hope this helped!!!