So I'm attempting to use a RemoteEvent to tween a joint from a server script and the loop steps 1/60th of a second because it's connected to RenderStepped, but for some reason the function that tweens the joint tweens the joint in a very choppy manner instead of smoothly like how I want it to run, is there any reason for this? Or do RemoteEvents just not work with RenderStepped? Thanks.
Here's the remoteEvent code:
local lerpCF = script:WaitForChild("lerpCF")
function lerpCF.OnServerInvoke(_, Joint, Prop, startCF, endCF, Alpha)
Joint[Prop] = startCF:lerp(endCF, Alpha)
end
Here's a tweenJoint code:
function tweenJoint(Joint, newC0, newC1, Alpha, Duration)
spawn(function()
local newCode = math.random(-1e9, 1e9)
local tweenIndicator = createTweenIndicator:InvokeServer(Joint, newCode)
if Duration <= 0 then
if newC0 then Joint.C0 = newC0 end
if newC1 then Joint.C1 = newC1 end
else
local Increment = 1.5 / Duration
local startC0 = Joint.C0
local startC1 = Joint.C1
local X = 0
while true do
RS.RenderStepped:wait()
local newX = X + Increment
X = (newX > 90 and 90 or newX)
if tweenIndicator.Value ~= newCode then break end
local T = tick()
if newC0 then lerpCF:InvokeServer(Joint, "C0", startC0, newC0, Alpha(X)) end
if newC1 then lerpCF:InvokeServer(Joint, "C1", startC1, newC1, Alpha(X)) end
print(tick() - T) --This prints some number near 0.03, which slows down the loop
if X == 90 then break end
end
end
deleteTweenIndicator:InvokeServer(tweenIndicator, newCode)
end)
end

2 comments
This helps, but here's the thing though, this server script is in 1 tool that each player will have, and same with the client script. I want the client to have the joint tween at 1/60th of a second, but it's fine if other players see a slightly slower speed in tweening. So will this method that you provided allow me to tween joints at a 1/60th speed to the client and possibly to the server as well
The way I set up my scripts is having one server script inside SSS which handles all the replication stuff (mostly just telling clients to do this and that) and all the RemoteEvents inside ReplicatedStorage because there's no need for a new event&script instance for each client which I from your setup understood you're doing. To answer your question: yes, it will. There's no point doing it server