Button registed as clicked, multiple times?

Hi, I am currently Making a multiplayer feature for my game, but there is a problem.

When i click the button, using a simple MouseButton1Click, it registreres more clicks.

Here is an example:

Server:

game.ReplicatedStorage.Remotes.ExampleRemote.OnServerEvent:Connect(Function(player)
–Varibles
local PlrGui = player.PlayerGui
local MultiplayerHostFrame = PlrGui.Misc.MultiplayerHost
local Temp = game.ReplicatedStorage.Templates.InvitePlayerTemplate

    MultiplayerHostFrame.AddPlrs.MouseButton1Click:Connect(function()
       print("Clicked")
   end)

end)

Client:

script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Parent.Parent.Enabled = false
script.Parent.Parent.Parent.Parent.Parent.Parent.Misc.MultiplayerHost.Visible = true
game.ReplicatedStorage.Remotes.StartMultiplayerLobby:FireServer()
end)

As you can see from the video, the more times i run the script function. The more times the button is being registred as pressed. Do anyone have something i could do to fix this?

1 Like

I am really stupid.

Bassicly before i posted this i tried to do something like this:
local PlrGui = player.PlayerGui
local MultiplayerHostFrame = PlrGui.Misc.MultiplayerHost
local conn = nil

conn = MultiplayerHostFrame.AddPlrs.MouseButton1Click:Connect(funciton()
–Real Code here
end)

MultiplayerHostFrame.AddPlrs.MouseButton1Click:Connect(function()
print(“Clicked”)
end)

Remotes.ExampleRemote.MphClosed.OnServerEvent:Connect(function()
conn:Disconnect()
end)

So the bug for me is that the conn wouldnt disconnect the print function because it wasnt connected to the value named conn

just leaving this there, if anyone in the future has the same problem

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