Tweening on Client or Server?

Hello! I’m making a game, where I tween a preset above player’s head. Currently, I’m handling all the tweening on Server. It is alright, until I hit 210+ ping, it becomes a bit laggy and on phone it is very laggy. So my question is, should I handle tweening on Client?

I can send the script if you want, but I think it is not needed at the moment.

1 Like

Special effects, such as tweening, should be handled on the client. This is to reduce the load on the server. The server usually does not handle visual effects (and should never)

4 Likes

The short answer is: If you can yes. Do it on the client.

You dont want to dedicate the server to perform a lot of tasks such as tweening as it can drastically descrease performance instead you want to FireClient() whenever a tween is needed and perform it via the local machine although there are cases where you may want to do it on the server, I dont think you need to here.

1 Like

Okay, thank you. I have one more question. This is my script:

function TweenPreset(speed)
	local TweenService = game:GetService("TweenService")
	local Preset = workspace.SelectedPreset.Preset
	local PresetRoot = Preset.SkyPieceCenter
	
	

local PresetInfo = TweenInfo.new(speed, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

local goal = {}
goal.CFrame = CFrame.new(0,-0.5,0)

local goal2 = {}
goal2.Transparency = 0

local PresetMove = TweenService:Create(PresetRoot, PresetInfo, goal)

--print("Starting Tween")

for i, part in pairs(workspace.Shadow:GetChildren()) do
	if part.Name ~= "SkyPieceCenter" then
	local PresetTween = TweenService:Create(part, PresetInfo, goal2)
	PresetTween:Play()
	end
end
PresetMove:Play()
print("Moving")
wait(speed-.1)
workspace.Shadow:Destroy()
wait(.1)
workspace.Sounds.Thud1:Play()
wait(.1)
workspace.SelectedPreset.Preset:Destroy()
	--workspace.Shadow:Destroy()	
	
end

I need to know, if I should make the Preset on the client, or if I can just pass it through the Remote Event?

EDIT: Also, I’m getting .Touched event on the server, if the player touches the tweening preset, they get killed. How should I handle it now?

You can do it either way.

I would do it on the client as then it will involve less remotes and therefore less server to client lag.

My bad, I explained it wrong. I want to know, if I should Clone the Preset on Client or I can just do workspace.path.to.the.preset. ?

You can just do workspace.path to get the preset on the client if its not created on the server, no need to clone.

I create (clone) the preset on server. So is it alright doing the workspace.path on the Client then?

So if you do this on the server:

local Preset = workspace.Preset:Clone()

Remote:FireClient(Player, Preset) then use the cloned preset.

Server

local preset = game:GetService("ServerStorage").Preset:Clone()
preset.Parent = workspace

Client
local preset = workspace.Preset

This is how I do it now and it works.

EDIT: Should I destroy it on client or server?

1 Like

I solved it thanks for help, revetments and MineDevs, I don’t know who should I give solution to, since you guys both helped! :slightly_smiling_face:

2 Likes

If I were you I’d only ever tween or do effects on the client-side, as doing it on the server would induce a large load and as such more server to client lag.

Clone the preset on the client.

Yes, you should handle CFrame tweening on the client, I used to do CFrame tweening on the server and then whilst making a spinning part using tweens, I realized my script activity started to skyrocket and lag the server.