Kicking Out Script

So, I have made a gamepass that if you have the gamepass, and have clicked the textbutton, it will kick them. Now my problem is, I can’t figure out how I would go about the Activation/Deactivation part.

Here’s the GUI in the viewport, and in explorer:

Here’s my script for reference
SCRIPT REMOVED

If you mean checking if the gui is shown then you can do Gui.Enabled to check

Oops, I made a typo, I meant the text button.

So do you want to know how you can check when the button is clicked or how to check when it’s visible?

Yes, I would like to know when the button has been clicked, and when its clicked again, to deactivate it, so that they can choose if they want to kick. So, lets say they’re playing with their friend and don’t want to kick them. Then they just don’t click. If they want to kick someone, they’ll click, and it will stay on. When they want to turn it off again, they will click it again to turn it off. I also have to go afk for a bit so I’ll probably respond a bit late.

You can do something like this for enabling the gui when clicking a button

TextButton.MouseButton1Click:Connect(function()
     KickGui.Enabled = not KickGui.Enabled
end)

OK, I might be able to insert that. After I’m back on my pc and try it , I’ll tell you.

I just realized I’m an idiot. Here’s the scripts though if anyone wants them for their own problem.
Here’s server script for kicking. Put in only a snippet because I don’t want anyone copying it.


						if Humanoid.Health < 1 then

						
							Player.leaderstats.moneys.Value = Player.leaderstats.moneys.Value + 50
							if 	Player and mps:UserOwnsGamePassAsync(Player.UserId,23171784)  then 
							if game.StarterGui.KickGUI.Enabled == false then
								
								local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)	
									plr:Kick("You've been kicked by someone who wasted their money")
								else
									print("not on")
								end
							
							

			
					
					
								
			

Here is the local script handling the enabled and click detection:

local mps = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function(plr)
	
	if plr and mps:UserOwnsGamePassAsync(plr.UserId, 23171784) then
	if game.StarterGui.KickGUI.Enabled == true then
		game.StarterGui.KickGUI.Enabled = false 
		script.Parent.Text = "ACTIVATED"
	elseif game.StarterGui.KickGUI.Enabled == false then
		game.StarterGui.KickGUI.Enabled = true
		script.Parent.Text = "Slap Out! *FOR GAMEPASS*"
		end 
	else 
		script.Parent.Text = "no gamepass "
		wait(1)
		script.Parent.Text = "Slap Out! *FOR GAMEPASS*"
		end
end)