I need a way for my remote events to get the players mouse position 5 seconds AFTER the event is fired. Obviously using the value that comes with the event will be 5 seconds old so I came up with a new method.
I plan to have a local script that constantly fires an event which sends mouse.Hit to the server which is then stored in a CFrame value. Obviously it will be delayed if you are lagging but it will be half as delayed compared to sending a remote function invoke to the client which then has to get sent back. I can’t really see any other way to achieve this but I am worried that this has the potential to cause lag with the event being fired so often. Here are some demo scripts that are not made properly for multiplayer yet but they show the idea.
Client :
local RunService = game:GetService("RunService")
RunService.Heartbeat:Connect(function()
game.ReplicatedStorage.PingEvent:FireServer(game.Players.LocalPlayer:GetMouse().Hit)
end)
Server:
game.ReplicatedStorage.PingEvent.OnServerEvent:Connect(function(plr,Hit)
script.MouseCFrame.Value = Hit
end)