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
Example
Server
local tool = script.Parent
local remotefunction = tool:WaitForChild("RemoteFunction")
local part = nil
local playerservice = game:GetService("Players")
tool.Activated:Connect(function()
part = Instance.new("Part")
part.Anchored = true
part.CFrame = tool.Parent.PrimaryPart.CFrame
part.Parent = tool.Parent
end)
tool.Deactivated:Connect(function()
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 = CFrame.new(part.Position, mousepos)
end)
Client
local remotefunction = script.Parent:WaitForChild("RemoteFunction")
remotefunction.OnClientEvent = function()
local mouse = game.Players.LocalPlayer:GetMouse()
return mouse.hit.p
end
Once again, according to the roblox dev site, doing this is discouraged. I'm looking for a way to safely retrieve data.

1 comment
It's OnClientInvoke*