How do I minimize the latency of client-sided character tweens?

I was making a roll mechanic where by interacting with a ProximityPrompt your character will play an animation alongside a tween that brings you to the opposing side of a gap. My code works but, while the tween plays nicely in the client of the rolling character, even though I’m tweening for other players it still looks choppy for everyone else. How could I compensate the lag?

function checkTweenLength(walkSpeed: number)
	if walkSpeed > dwalkSpeed then
		return procAnim.Length - 0.15
	else
		return procAnim.Length - 0.25
	end
end

--the server passes the character of the rolling player along with two roots as position guides
rollEvent.OnClientEvent:Connect(function(rChar: Model, roota: BasePart, rootb: BasePart)
	local hrp = rChar:WaitForChild("HumanoidRootPart")
	local cwalkSpeed = rChar.Humanoid.WalkSpeed
	print(rChar.Name, char.Name)
	if rChar == char then
		if not canRoll then return end
		canRoll = false
		hrp.Anchored = true
		hrp.CFrame = roota.CFrame
		rChar.Humanoid.WalkSpeed = 0
		local rollTween = ts:Create(hrp, TweenInfo.new(checkTweenLength(cwalkSpeed), Enum.EasingStyle.Linear), {CFrame = CFrame.lookAt(rootb.Position, rootb.Position + roota.CFrame.LookVector)})
		procAnim:Play()
		rollTween:Play()
		rollTween.Completed:Wait()
		rChar.Humanoid.WalkSpeed = dwalkSpeed
		hrp.Anchored = false
		hrp.Position = rootb.Position
		speedEvent:Fire(cwalkSpeed)
		task.wait(cooldownTime)
		canRoll = true
	else
		local rollTween = ts:Create(hrp, TweenInfo.new(checkTweenLength(cwalkSpeed), Enum.EasingStyle.Linear), {CFrame = CFrame.lookAt(rootb.Position, rootb.Position + roota.CFrame.LookVector)})
		rollTween:Play()
		rollTween.Completed:Wait()
	end
end) 
1 Like

Found this module called TweenService Plus, currently experimenting with it as it seems to implement some type of lag compensation. I’ll come back and mark it as solved if I get any results (also bumping this)

1 Like

Forgot to mention this but I implemented a server-side debounce to the rolling. Don’t think there’s also a way to make it work like I want to without TweenService so I’ll be leaving this as the solution

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.