Tweening server lag?

Hi there,

I’ve got this tween that runs when a Player has died, However there is visual delay on the Tween for the rest of the Server (Not all the time) but its not ideal.

Not sure how id go about fixing such an issue as I’m pretty new to scripting and tweening in general.

Thanks,

function deatheffect(player,hit)
local tweenservice = game:GetService(“TweenService”)
local char = hit.Parent
local humanoidRoot = char:FindFirstChild(“HumanoidRootPart”)
local travel = humanoidRoot.Position + Vector3.new(0,20,0)
local char = hit.Parent

humanoidRoot.Anchored = true
humanoidRoot.Velocity = Vector3.new(0,50,0)
char:SetPrimaryPartCFrame(humanoidRoot.CFrame)

  local tweeninfo = TweenInfo.new(
  	10,
  	Enum.EasingStyle.Cubic,
  	Enum.EasingDirection.InOut,
  	0,
  	false,
  	0
  )
  local playerFly = {
  Position = travel
  }

local Tween = tweenservice:Create(humanoidRoot,tweeninfo,playerFly)
Tween:Play()
wait(4)
humanoidRoot.Anchored = false
end

Thanks,

2 Likes

Did u use SetNetworkOwner? that might be the issue

Not much knowledge on that, What thing would i set it to?

1 Like

I’ve recently started to move a lot of my Tweens to be client side only for things like special effects that don’t affect gameplay.
You could make that above a local script and get it to activate by firing a remote event to all clients.

This.

TweenService eats up a lot of the server’s resources. Especially when you take into account that the server also has to replicate changes to every player at the same time while tweening. Always, always, always, when possible, use RemoteEvents to have the clients do all the tweening. Especially with physics.

It’s much faster to tell nine children to clean up their own mess, than to clean up each of their messes on your own.

Here’s a resource on client-server relationship, and here’s more about RemoteEvents.

4 Likes

It’s much faster to tell nine children to clean up their own mess, than to clean up each of their messes on your own.

I like that!

1 Like