Remote Event being recieved multiple times

In a local script, a remote is fired ONCE and a print statement is also fired ONCE, however on a server script, when the remote is recieved the code runs multiple times

also, every time the remote is recieved the code gets ran more and more, so if the remote is recieved 3 times the code will run like 20 times but if its recieved 10 times it will run like 90 times when it should always run once

example

LOCAL SCRIPT

local coolremote = script.Parent.RemoteEvent
PlayerGetsHitFunction:Connect(function(hit, hum, stuff)
coolremote:FireServer()
print("Client Detects Hit") --PRINTS ONCE
end)

SERVER SCRIPT
local coolremote = script.Parent.RemoteEvent
coolremote.OnServerEvent:Connect(function(hit, hum, stuff)
print("Recieved!") --Every time this remote is recieved, this prints more and more
end)

I’m not sure what kind of hierarchy you have in your explorer. There might be multiple local scripts firing that event simultaneously.

Also, this part has an error:

coolremote.OnServerEvent:Connect(function(hit, hum, stuff)

Sending (hit, hum, stuff) will be received as (player, hit, hum, stuff).
RemoteEvents pass the Player Instance as the first variable to a OnServerEvent event. You should change it to this instead:

coolremote.OnServerEvent:Connect(function(player, hit, hum, stuff)

shouldnt it look, something like:

-- LOCAL SCRIPT

local remote = script.Parent.RemoteEvent

local function PlayerGetsHitFunction(hit, hum, stuff)
	remote:FireServer(hit, hum, stuff)
	print("Client Detects Hit")
end

-- SERVER SCRIPT

local remote = script.Parent.RemoteEvent

remote.OnServerEvent:Connect(function(player, hit, hum, stuff)
	print("Recieved!")
end)

“I’m not sure what kind of hierarchy you have in your explorer. There might be multiple local scripts firing that event simultaneously.”

If that’s the case then shouldn’t he be doing:

local action = “…”

Something that allows him to check if the action that was fired through the event, is true…

also only 1 script is firing the event

it was an example omg bruh wwwww

fixed it wwwwwwwwwwwwwwwwwwwwwww

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