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

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?

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:

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)
Ad
Log in to vote
0
Answered by
Bulvyte 388 Moderation Voter
8 years ago

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)

Answer this question