Remotes acting as if they're in a "queue"


image

In the preview, the “Side Weapon” is connect on a M1Up event but the connection is made when the player presses on the item (so it acts like a press and hold). The problem is when you see me use the weapon let’s say 4 times, once I press on the side weapon there is a bunch of errors that print out 4 times. So basically the RemoteEvent sets up a queue which goes in once a :Connect is set up? Is this normal and is there a way to disable this?

1 Like

Is m1up made everytime the remote event is called?
If so, I suggest moving m1up somewhere outside the scope of the :Connect event. By doing so, everytime the RemoteEvent, you can do

if m1up then
  m1up:Disconnect()
end
m1up = CharacterService.Client.M1Up:Connect()
1 Like

I’ve also noticed, are you using Knit by chance?
If you are then, I suggest just moving CharacterService.M1Up under KnitService:KnitStart() instead. Plus, you really don’t have to connect and disconnect the RemoteEvents everytime.

1 Like

Yes, though this connection is inside a module script and not an Knit service.

Basically when you click a module.Activate() on the weapon module is called which creates the connection to listen for the mouse going up. The problem is the previous remotes from before trigger all at once when the :Connect starts to listen.
image


Here are 2 pictures of the code so you can understand situation better.

Move m1up outside module:Activate and do

if m1up then
   m1up:Disconnect()
end

The connection depends on the variables that are assigned when the :Activate() is called and I can’t assign them outside of the function because the function passes the players character as an argument.

It’s generally not a big problem since it causes errors and doesn’t break the code thankfully, but this happened to me in another project which it did cause problems at.

No I meant something like

local m1up

function module:Activate()
  if m1up then
    m1up:Disconnect()
  end
 m1up = CharacterService.Client.M1Up:Connect(function(player)

end)
end