How do I open an frame (from ScreenGui) by using an TextButton (SurfaceGui)?

I want open an frame from the ScreenGui by clicking in a Textbutton from an SurfaceGui. However, I’m having trouble with it, I’ve tried using localscript, but it doesn’t even work inside an TextButton.

image
image

– ServerScript inside an TextButton

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Protocols = ReplicatedStorage.Event:WaitForChild("Protocols")

local Button = script.Parent
local Event = Protocols.ProtocolFrame

Button.MouseButton1Click:Connect(function()
	print("Clicked")
	Event:FireClient()
end)

– ServerScript inside an ServerScriptService

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Protocols = ReplicatedStorage.Event:WaitForChild("Protocols")

local teamColors = {
	BrickColor.new("Black"),
	BrickColor.new("Dark stone grey"),
	BrickColor.new("Navy blue"),
	BrickColor.new("Really black")
}

local ProtocolFrame = Protocols:FindFirstChild("ProtocolFrame")

ProtocolFrame.OnServerEvent:Connect(function(player)
	print("Printed")
	local PlayerGui = player.PlayerGui
	local PlayerTeam = player.TeamColor
	print(PlayerTeam)
	for _, Color in pairs(teamColors) do
		if PlayerTeam == Color then
			print("Passed Test")
			local ProService = PlayerGui:WaitForChild("ProtocolService")
			ProService.ProtocolFrame.Visible = true
		end
	end
end)

It shows an error aswell from the first script

  15:09:21.909  Argument 1 missing or nil  -  Servidor - CallEvent:9

Like again, I tried to use an LocalScript and open without needing to use any event’s (as I’m not still used with event system) however, it doesn’t do anything, I’ve putted an print to see and doesn’t even print out in the ouput.

local Folder = game.Workspace.Map.CCI.Script.Tablets
local Gui = script.Parent

local Button = {}
for i,v in pairs(Folder:GetDescendants()) do
	if v:IsA('TextButton') then
		table.insert(Button,v)
	end
end

for _, textButton in ipairs(Button) do
	textButton.MouseButton1Click:Connect(function()
		if textButton.Name == "Prot" then
			Gui.ProtocolFrame.Visible = true
		end
	end)
end

Has been fixed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.