The button is used to open and close a frame in a Gui. When I click on the button in Studio > Test, it works but, but when I click on the button in server mode, nothing happens...
open = false function onClicked() if open == false then open = true script.Parent:FindFirstChild("ClickSound"):Play() script.Parent.Parent.ShopGUI.Visible = true else open = false script.Parent:FindFirstChild("ClickSound"):Play() script.Parent.Parent.ShopGUI.Visible = false end end script.Parent.MouseButton1Down:connect(onClicked)
Can someone tell me what I'm doing wrong?
I converted this into local script:
Player = game.Players.LocalPlayer function onClicked() script.Parent:FindFirstChild("ClickSound"):Play() if Player.PlayerGui.ScreenGui.ShopGUI.Visible == false then Player.PlayerGui.ScreenGui.ShopGUI.Visible = true elseif Player.PlayerGui.ScreenGui.ShopGUI.Visible == true then Player.PlayerGui.ScreenGui.ShopGUI.Visible = false end end script.Parent.MouseButton1Down:connect(onClicked)
This should work flawless
local Player = game.Players.LocalPlayer local ClickSound = script.Parent:WaitForChild("ClickSound") local open = false local button = script.Parent button.MouseButton1Down:connect(function() if not open then open = true ClickSound:Play() Player.PlayerGui.ScreenGui.ShopGUI.Visible = true else open = false Player.PlayerGui.ScreenGui.ShopGUI.Visible = false end end)