Is that possible? (sorry for lack of contents)
pcall(function()
RemoteEvent:FireServer()
end)
detecting when it fails and retrying?
local function FireServer(remote, ...)
local success, err = pcall(function()
remote:FireServer(...)
end)
if not success then
warn(err)
task.wait()
return FireServer(remote, ...)
end
end
I’m pretty sure FireServer() retries until successful by and of itself, no pcall required.
I’m confused about this thread.
If your RemoteEvent is returning an error, then you’re most likely receiving errors from the server, not the client. From my understanding, and I could be mistaken, firing the RemoteEvent from the client should not return any errors.
If you are receiving an error it’s most likely the server handling the event, and erroring whilst doing that. Ensure you double check the server code that’s connected to the event.
Furthermore, refrain from using pcall in situations like these, all it’s doing is putting a bandaid on broken code, it’s not actually fixing anything.
This will give a syntax error because ...
is bound to a function, not scope, and you’re creating a new function with pcall
.
Also as @NodeSupport said, FireServer()
shouldn’t ever error, but for educational purposes here’s a good way of doing it, with comparison for easier understanding:
--normal calls
remote:FireServer()
remote:FireServer("arg1", "arg2")
--just pcalling
pcall(remote.FireServer, remote)
pcall(remote.FireServer, remote, "arg1", "arg2")
--pcalling and checking the error
local success, err = pcall(remote.FireServer, remote, "arg1", "arg2")
if not success then
warn("Error occurred:", err)
end