Help with server to client replication

So, I have a remote event and it does Tweens and its sent from the server to client. My issue is that the part to alter sometimes (and by that i mean 99.99% of the time) isn’t replicated yet on the client. Sure, I could fix it by doing a task.wait(0.1) or waiting some time on the server to do it but it gets so exhausting and I just want a simple way to do it that’s on the client, I tried looking for solutions but never got anything that fit what I’m looking for. The code:

 if Data.Method == "Tween" then
	local infoData = Data.Info
	local tweenInfo = TweenInfo.new(
		infoData.Time,
		infoData.Style,
		infoData.Direction,
		infoData.RepeatCount or 0,
		infoData.Reverses or false,
		infoData.DelayTime or 0
	)
				
	TweenService:Create(Data.PartToAlter, tweenInfo, Data.PropertySet):Play()
end
1 Like

Why do you need sending all that?
Why won’t you just hardcode it on client instead?

Don’t send the actual TweenInfo object to the client.
Instead just send the data you need like Time, DelayTime, etc as normal variables to the client.
Then on the client you create the tween locally and add the needed values that the server sent it.

Or you create the entire tween on the client with all values and the server simply sends a remote when the client should do the tween, it depends on your needs.

1 Like

I need to reuse it across multiple scripts and sometimes I need to use different easing styles and such.

I’m not, I’m sending the values like the time, easing direction and style to the client.. but I don’t see how this is related to my issue.

You can’t send TweenInfo across replication boundaries, in this case you would genuinely have to send each of the values or find an alternative solution.

To answer your question there is no easy way to do this. You basically have to just wait, though you can wait “faster” than wait(0.1) by just not giving a number and doing a while not part do task.wait() end (though you may want a timeout so you don’t create a memory leak with running processes).

But yeah, there is no :WaitOnPart type thing that will work in all scenarios here even though there are things like :WaitForChild()

Normally how I do these types of things is I actually handle stuff like the tweens myself and I can simply skip that frame until the part exists, but that’s not usually what people want (I tween properties that tweenservice doesn’t support)

I did send each of the values. Where does it say I didn’t?

Alright sure. I guess I can just implement a function that waits for it for me, so thanks.

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