MouseButton1Click is not a valid member

Hello, I’ve written a script for a button that allows you to exit a queue although while testing this error displays. Any help is appreciated.

Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local LeaveEvent = ReplicatedStorage.Events:FindFirstChild("LeaveEvent")
local Player = Players.LocalPlayer

local Leave = Player.PlayerGui.Leave:WaitForChild("Leave")

LeaveEvent.OnClientEvent:Connect(function()
	Leave.Visible = true
end)

Leave.MouseButton1Click:Connect(function()
	LeaveEvent:FireServer()
	Leave.Visible = false
end)

Error:

StarterGui:

image

TextLabels do not contain a clickable source, use a TextButton or a ImageButton to contain a source, unfortunately it will not be able to be clickable.

1 Like

“Leave” is a TextLabel. It does not have a MouseButton1Click event. You need to replace that with a TextButton if you want to use the event.

1 Like

Oh I see I accidently used a text label. Thanks for the help.

1 Like