Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

3 comments

0

What kinda script are you using and where is it located?

0

In using a normal script and its inside the text button

0

I'm*

2 answers

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.