Still have questions? Join our Discord server and get real time help.
Log in to vote

RemoteFunction from Server to Client concerns?

Asked by
Despayr 460 Moderation Voter
6 months ago

The Roblox Developer Site states that a Remote Function that uses the server to retrieve information from the client is discouraged due to the reason that if the Client disconnects before it can retrieve data, the server will hang forever.

I was going to use the Remote Function so that the server could retrieve the mouse position from the client, but I'm worried that the client could disconnect and leave the server hanging. Would there be any solution to this problem? I'd rather not have to rely on many remote events.

The reason that I cannot send the mouse position through the remote (tool for now) is because there is a time difference between when the remote is activated, and when I want the mouse position just in case it changes



local tool = script.Parent
local remotefunction = tool:WaitForChild("RemoteFunction")
local part = nil

local playerservice = game:GetService("Players")

    part ="Part")
    part.Anchored = true
    part.CFrame = tool.Parent.PrimaryPart.CFrame
    part.Parent = tool.Parent

    if part == nil then return end

    local player = playerservice:GetPlayerFromCharacter(tool.Parent)
    if not player then return end
    local mousepos = remotefunction:InvokeClient(player)

    part.CFrame =, mousepos)


local remotefunction = script.Parent:WaitForChild("RemoteFunction")

remotefunction.OnClientEvent = function()
    local mouse = game.Players.LocalPlayer:GetMouse()
    return mouse.hit.p

Once again, according to the roblox dev site, doing this is discouraged. I'm looking for a way to safely retrieve data.

It's OnClientInvoke* Ziffixture 5655 — 6mo

1 answer

Log in to vote
Answered by 6 months ago

Just swap out your RemoteFunction for a RemoteEvent.

You will have to rewrite your server side a bit as you can no longer expect a direct result, instead the result will have to come from a OnServerEvent. This way you basically replicate a RemoteFunction but you manually tell the client to fire the event on the server.

It will have to do. I'll have the server fire the event to the client, the client will then fire to the server, and finally, the server will add the mouse position to a table Despayr 460 — 6mo

Answer this question