Client-side tweens playing choppy, segmented when the client did not call the remote event

I want to have both client-side tweens that are called by a server event move an attachment smoothly. When one client sends an input to call a remote the server fires an event on all clients that plays the tween on an attachment. The client that sent the remote event has a normal tween, while the other’s segmented and stays in one spot before teleporting to the next, instead of a smooth transition. This is odd because both the attachment and tween are handled by the client.

I recreated the problem in an example game here:
tweenExample.rbxl (76.0 KB)

Here is a video demonstrating the problem, a part is being repeatedly created on the tweened attachment to demonstrate:

local script

local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local tweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")
local playerGui = player:WaitForChild("PlayerGui")

uis.InputBegan:Connect(function(input, gameprocessed)
	if gameprocessed then return end
	if input.KeyCode == Enum.KeyCode.E then
		game.ReplicatedStorage.RemoteEvent:FireServer()
	end
end)

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
	local attachment0 = Instance.new("Attachment")
	local attachment1 = Instance.new("Attachment")
	local startPoint = player.Character["Right Arm"].Position - player.Character["Right Arm"].CFrame.UpVector
	local endPoint = player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame.LookVector*30
	attachment0.Parent = player.Character["Right Arm"]
	attachment0.WorldPosition =  startPoint
	attachment1.Position = startPoint
	attachment0.Orientation = Vector3.new(0, 0, 90)
	attachment1.Orientation = Vector3.new(0, 0, 90)
	attachment1.Parent = workspace
	local beam = Instance.new("Beam")
	beam.Texture = "rbxassetid://12694722890"
	beam.Color = ColorSequence.new(Color3.fromRGB(57, 57, 57))
	beam.Transparency = NumberSequence.new(0)
	beam.TextureSpeed = 0
	beam.TextureMode = "Static"
	beam.Segments = 10
	beam.Parent = attachment0
	beam.Attachment0 = attachment0
	beam.Attachment1 = attachment1
	beam.FaceCamera = true
	local tweenInfo = TweenInfo.new(.4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
	local tween = game:GetService("TweenService"):Create(attachment1, tweenInfo, {Position = endPoint})
	local tweenEnded = false
	tween:Play()
	tween.Completed:Connect(function()
		tweenEnded = true
	end)
	while tweenEnded == false do
		task.wait()
		local part = Instance.new("Part")
		part.Size = Vector3.new(1,1,1)
		part.Anchored = true
		part.CanCollide = false
		part.Parent = workspace
		part.Position = attachment1.WorldPosition
	end
end)

server script

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
	game.ReplicatedStorage.RemoteEvent:FireAllClients()
end)

I have read Tweens seem choppy / laggy even though it’s running on the client - Help and Feedback / Scripting Support - Developer Forum | Roblox
but I don’t think it described my problem as I’m only using one tween, and the choppiness is more ordered and uniform than theirs. Any help is greatly appreciated.

After testing, I’ve concluded that the problem only occurs because of roblox studio’s local server 2 player test. I tried to replicate the bug in a normal game with an alt and wasn’t able to, but when the clients in the studio local server receive the tween event, only the client who’s window is focused will tween correctly.

This makes testing in studio difficult though, does anyone know how I could fix this?

This is only because studio automatically throttles non-focused windows to save performance. I don’t believe there’s a workaround, but this is expected behavior. Just think of it like what somebody who is lagging will see.

it’s making the other window cap at 30 fps, I think there is a setting for that

To expand upon what the others are saying, when doing a multiple client test within studio, running several clients at once uses a lot of processing power on your computer. To relieve some of this, any client window that is not currently selected/focused will be limited to about 15 FPS if I remember correctly.

On the line of your code that reads while tweenEnded == false do, you have a task.wait() which loops and creates a visible part. task.wait() delays by about 1/30 of a second, which is 30Hz. But since an unfocused client’s framerate is half of that frequency, it can only produce a part every other frame. This means that your unfocused window can only produce half of the amount of parts as the fully functional window.