How to detect when the server script receives info from the local script firing an event

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to let the local script know that the event they fired was received
  2. What is the issue? Include screenshots / videos if possible!
    i thought maybe to use a bool to use as an indicator that it was received but i fear there will be latency when the bool changes and is replicated to the client??

I would just like to know if there are other ways to go about this

1 Like

You could use a Remote Function, instead of a Remote Event.
You fire the remote from client, and server returns an answer

Remote Function

1 Like

Fire local script to server script then have the server script fire back.
Local > Fires > Server
Server > Return Fires > Local

what are you trying to acheive by doing this? ill try to give the best solution

trying to sync server and client cooldowns

simple, just fire the remoteEvent once in both the server and the client, setup a debounce in the client side which sets to true when (e.g lunge a sword) and then sets back to false when it receives from the server. here’s a code exmaple:

client:

local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local tool = script.Parent

local db = false
tool.Activated:Connect(function()
      if db then return end
      db = true
      event:FireServer("info")
end)

event.OnClientEvent:Connect(function()
      db = false
end)

server:

local cooldown = 2
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, information)
      -- whatever you want to do in the server side
      task.wait(cooldown)
      game.ReplicatedStorage.RemoteEvent:FireClient(plr)
end)

i hope this is the solution your looking for.

1 Like

how would i make sure a exploiter cant just change the db himself and spam moves

i will try using a remotefunction

dam i forgot about that, its pretty simple you just do the debounce on the server too

local dbs = {}
local cooldown = 2
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, information)
      if dbs[plr.UserId] then return end
      dbs[plr.UserId] = true
      -- whatever you want to do in the server side
      task.wait(cooldown)
      dbs[plr.UserId] = nil
      game.ReplicatedStorage.RemoteEvent:FireClient(plr)
end)
1 Like

remote function is just the same thing.

1 Like