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)