Just a small thing that I should be able to do but sadly can’t
So I have this value which is taken from the client in a module script and I want to transfer it using the ModuleScript to a server-run part of the ModuleScript. Before you say anything, remote events or functions do not work here. I need the CFrame every single frame (this is dealt with in a LocalScript using RenderStepped) and passing the CFrame through the RemoteEvent every frame makes the game extremely laggy.
Here is the ModuleScript code:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local IsPropHeld: boolean = false
local RequiredPropCFrame = CFrame.new()
local PropSystem = {}
function PropSystem.GetPropPositionCFrame(PropPositionCFrame)
RequiredPropCFrame = PropPositionCFrame
end
function PropSystem.PropHeld(Prop, Attachment0)
for i = 0, 1, 0.01 do
Prop.CFrame = Prop.CFrame:Lerp(RequiredPropCFrame, i)
end
end
return PropSystem
Getting technical here, module scripts are replicated to the client when the game loads. Any functions you run in one is done locally from that user’s machine independently from functions the server runs. Because there independent you can’t say share data between them.
To my knowledge, remote events/functions are the only way for a client to communicate to the server.
In order to achieve what you want to do, you would need to send a remote event at a timed interval, say every 50-100 ms. Then, if you want to replicate it on the server as if it was every frame you would need to use some form of interpolation.
If you’re wondering, this is how every game even outside of Roblox does it. As sending so many requests to say update a player’s position would be unfeasible with today’s current internet infostructure.
So the only solution is using remote events? That sucks. I’ve tried putting it all on the client or the server but that’s caused problems (doing almost everything on the client doesn’t allow for collisions as those are all on the server and doing almost everything on the server doesn’t work).
So either I have to go fully back to the drawing board and redo everything, or I have to find a way to make it work with RemoteEvents. Hm.
Thanks for your help, very useful even if it is not exactly what I wanted to hear.