RemoteEvent is being recieved twice for some reason

So I have encountered a very strange issue - the RemoteEvent is firing once (Server Script), but however is being recieved twice (on LocalScript).

I found another post that had the same problem as me, however their solution didn’t work for me (they were just receiving the RemoteEvent twice).

A simple example of my code:

-- Server
client = PLAYER

event:RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("Remotes")

t = 1 --after what time to fire event (starting from the script run)
was = tick()

repeat wait() until tick()-was >= t

print("send")
event:FireClient(client)

-- Client
event:RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("Remotes")

event.OnClientEvent:Connect(function()
 print("receive") --this prints twice for whatever reason
end)

Please note that I do not want to use any debounces, since in my game it is possible for the event be binded twice in a row (in a short time period like 0.03 seconds), I just need to understand why the event could be firing twice, even if the code fires it once.

oh and yea sorry for my bad english if this post got spelling or grammatic mistakes

1 Like

The code you sent is very weird, why the weird way of waiting?

t = 1
was = tick()

repeat wait() until tick()-was >= t

--why not just use task.wait() or  wait() normally? --> wait(t) or task.wait(t)

Why assign the PLAYER variable to another variable?

client = PLAYER --does your code use the client variable for another purpose?

And not just call it using the PLAYER variable?

event:FireClient(PLAYER)

You’re going to have to give more information about your actual code as that code (besides the fact you seem to be indexing the Remotes folder) works fine.

1 Like

That might be stupid but… did you check if there’s another copy of your script or a duplicate of the fire code?

1 Like

Have u tried to add a debounce yet?

Using debounce seems to be a pretty hacky fix, and OP doesn’t want to use debounce too.

1 Like

My best guess is a duplicated script im not too sure.

I cannot use debounce in my game, since the event can be called twice in a short period of time.

I do not assign client to another variable, I just wanted to show that the client is the player.
But yea, I agree that I used a weird method of waiting.

(@EgizianoEG and @HP5C)
It prints the "send" once, but is being received twice on client (prints "received" twice for some reason). I double checked everything and haven’t found duplicate of script.

So I found the error - I used Script with Client RunContext, and for whatever reason, it got the event twice. So I decided to change the Script to LocalScript and… It started working. It recieved the event only once this time. I don’t understand why, but I think this is just a bug.

If someone finds it, please post this in #bug-reports, since I don’t have permission to create topics there yet.

1 Like

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