How to make tweens on a local script appear for all other players

Please let me know if this is more useful in another section of the dev forum, such as code review.

I am trying to remaster TurboFusion’s Gun Kit (Gun Kit v0.0.3 (V4 in progress) - Roblox) so that it works well today; a couple of issues with this that I have come across are as such:

  1. Player is in a different spot Server Side vs Client side.

  2. Gun animations (such as the reload animation) only play for the local player.

  3. Damages only enemies for the local player, not killing them.

  4. Bullets, bullet holes, and effects also only play for the local player.

I have been fixing these issues with a server-side script augmentation. That helps with issue 1 and will help 3 and 4, although I have yet to get that far. I tried making the animations also work via a server tween service that runs them, but that was jittery and made it look horrible.

Here is the crux of the issue. This script is so old all the animations are simply tweens from one spot to another. Here is the link to my most recent work fixing Turbo’s script Muffin Maker - Roblox. The tweens don’t even use tween service; they use numlerping. I want to see how to make the weird tween animations visible to other players, as my previous attempts lead the animations to be very jittery.

I did receive a tip on this post referencing another attempt at fixing this issue (Server Tweening animation is not smooth client side - #3 by Dev_Peashie) that the animations can be sent to other clients so that it would show up for them too. I find this strange and don’t think this is how eye candy games do this.

How would I make the tween animations visible to other players, just like how larger games do the same?

I have seen tutorials on how to make animations using the new animation builder. But that is a significant departure from how the script I’m working on does it. I hope to find a solution to this issue. Any extra information not provided can be asked for. I hope this is not too crazy of a request.

1 Like

I recognize that just posting the game with none of the code may be a issue if anyone helps me, but I cant bring myself to post the 4200 line script here. I am willing to give anyone who asks a copy of the scripts though.

Why you find it strange?

  • If you have a ServerScript that Plays a Tween, every Player in Server will see the animation, but that will jitter.

  • If you have a LocalScript that Plays a Tween, only that Client will see the animation, but, if every Client in game has the same LocalScript, then all Players will see the animation smoothly.

I dont know whats eye candy games or how they do it. But, playing animation on ClientSide is very common and widely used.

It seems rather convoluted and complicated.
I have tried this, and firing server to fire client back to the same script is why I find it strange. It just seems weird and overly complicated, like there should be a easier way to do this.

client side:

repeat wait() until game.Players.LocalPlayer
local tween=game:GetService("TweenService")
local part=game.Workspace.Part
local info=TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,5,false,0)
local goal={Position=Vector3.new(5,5,5)}
local move=tween:Create(part,info,goal)

game.ReplicatedStorage.Event.OnClientEvent:Connect(function(part,goal)
	local move=tween:Create(part,info,goal)
	move:Play()
end)
if game.Players.LocalPlayer.Name=="Player1" then --makes sure player two does not do this aswell
	wait(2)
	move:Play()
	game.ReplicatedStorage.Event:FireServer(part,goal)
end

server side:

local event=game.ReplicatedStorage:WaitForChild("Event")

event.OnServerEvent:Connect(function(player,part,goal)
	for _,Player in pairs(game.Players:GetChildren()) do
		if Player ~= player then --makes sure it does not fire to the client that called the server.
			event:FireClient(Player,part,goal)
		end
	end
end)

I have some doubts about your approach. For a reload animation you gonna use Tweens?
Would be better if you use Animator/AnimationTracks for that, will look better, will be easier and if its done from client it will replicate to server automatically.


Your code doesnt seem convoluted or complicated to me, you could improve it a bit, for example remove the lines where you check if Player ~= player then to FireClient, just FireAllClients().

I tested this:
(Notice that the jittery in the video is because Im changing the window on focus, and the unfocused one drops the FPS)
Client:

local TS = game:GetService("TweenService")
local Part = workspace:WaitForChild("Button")

game.ReplicatedStorage:WaitForChild("TweenCL").OnClientEvent:Connect(function(part, goal)
	TS:Create(part, TweenInfo.new(1), goal):Play()
end)

if game.Players.LocalPlayer.Name ~= "Player2" then
	game.ReplicatedStorage:WaitForChild("TweenCL"):FireServer(Part, Part.CFrame)
end

Server:

game.ReplicatedStorage:WaitForChild("TweenCL").OnServerEvent:Connect(function(plr, part, partCFrame)
	local Goal = {CFrame = partCFrame * CFrame.new(0,0,8)}
	game.ReplicatedStorage:WaitForChild("TweenCL"):FireAllClients(part, Goal)
end)

I made the server to calculate the goal position, idk the purpose of your system, so I just did it, but could be the client sending the goal with proper sanity checks. Or could be the server deciding the goal with a table of possible goals, idk, just ignore it if its not related with your system

1 Like

I dont need to make tweens do all the work. But the original does do it that way, and I want to keep it that way out of respect for the original. I think it has some benefits with tweens. As a case study, when you ADS, the ADS tween plays, but then can be interrupted if you stop ADSing. I am not sure if that is possible with regular animations. I thank you for your help and your support for my last post as well.

1 Like

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