Issue with script handling UI Visibility

Hey there! I’m trying to make a Click ClickDetector fire a Bindable Event when it’s clicked.

When I Click on the ClickDetector nothing happens, I don’t get an error in the console or anything

This is the script inside of the Click ClickDetector

local p1 = {
	v1 = game.Teams.Civilian,
	v2 = game.Teams.Police,
	v3 = game.Teams.Fire,
	v4 = game.Teams.DOT
}

script.Parent.MouseClick:Connect(function(Player)
	if Player.TeamColor == p1.v1.TeamColor or
		Player.TeamColor == p1.v2.TeamColor or
		Player.TeamColor == p1.v3.TeamColor or
		Player.TeamColor == p1.v4.TeamColor then

		Player.PlayerGui.GameMenus.InDevelopment.Visible = false
		Player.PlayerGui.GameMenus.InDevelopment.OpenEvent:Fire()
		Player.PlayerGui.GameMenus.InDevelopment.Title.Text = "ATM"
	end
end)

This is the script inside of the Frame

local Parent = script.Parent
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

Parent.OpenEvent.Event:Connect(function()
	_G.OpenEvent(Parent)
end)

Parent.Close.MouseButton1Click:Connect(function()
	_G.CloseMenu(Parent)
end)

Use OnServerEvent to fire the Bindable Event. Is “Parent” the part with the ClickDetector?

(Script in the frame)

local Parent = script.Parent
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

Parent.OpenEvent.OnServerEvent:Connect(function()
	_G.OpenEvent(Parent)
end)

Parent.Close.MouseButton1Click:Connect(function()
	_G.CloseMenu(Parent)
end)

I thought OnServerEvent only works with RemoteEvents

Bindables only work server-server and client-client. Switch it to a RemoteEvent and use OnServerEvent to update the player Gui.

1 Like