Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

*FIXED* Why does my text button only work in Studio > Test and not in Server mode?

Asked by
Seraine 103
8 years ago
Edited 8 years ago

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...

01open = false
02function onClicked()
03    if open == false then
04        open = true
05        script.Parent:FindFirstChild("ClickSound"):Play()
06        script.Parent.Parent.ShopGUI.Visible = true
07 
08    else
09        open = false
10        script.Parent:FindFirstChild("ClickSound"):Play()
11        script.Parent.Parent.ShopGUI.Visible = false
12    end
13end
14 
15script.Parent.MouseButton1Down:connect(onClicked)

Can someone tell me what I'm doing wrong?

0
What kinda script are you using and where is it located? User#11440 120 — 8y
0
In using a normal script and its inside the text button Seraine 103 — 8y
0
I'm* Seraine 103 — 8y

2 answers

Log in to vote
0
Answered by
Seraine 103
8 years ago

I converted this into local script:

01Player = game.Players.LocalPlayer
02function onClicked()
03    script.Parent:FindFirstChild("ClickSound"):Play()
04    if Player.PlayerGui.ScreenGui.ShopGUI.Visible == false then
05        Player.PlayerGui.ScreenGui.ShopGUI.Visible = true
06 
07    elseif Player.PlayerGui.ScreenGui.ShopGUI.Visible == true then
08        Player.PlayerGui.ScreenGui.ShopGUI.Visible = false
09end
10end
11 
12script.Parent.MouseButton1Down:connect(onClicked)
Ad
Log in to vote
0
Answered by
Bulvyte 388 Moderation Voter
8 years ago

This should work flawless

01local Player = game.Players.LocalPlayer
02local ClickSound = script.Parent:WaitForChild("ClickSound")
03local open = false
04local button = script.Parent
05 
06button.MouseButton1Down:connect(function()
07 
08if not open then
09    open = true
10    ClickSound:Play()
11    Player.PlayerGui.ScreenGui.ShopGUI.Visible = true
12else
13    open = false
14    Player.PlayerGui.ScreenGui.ShopGUI.Visible = false
15    end
16end)

Answer this question