Viewportframe character live action is working in studio but not working in game experience

i have problem about something the problem is i can see my avatar’s current movements like live actions but at the game its look like a statue there is no any action can u guys take a look
in studio


in game

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")

-- Remote Events
local StartChat = ReplicatedStorage.RemoteEvents.StartChat
local StopChat = ReplicatedStorage.RemoteEvents.StopChat
local NextChat = ReplicatedStorage.RemoteEvents.NextChat
local SendMessageEvent = ReplicatedStorage.RemoteEvents.SendMessage
local UpdateCharacterViewports = ReplicatedStorage.RemoteEvents.UpdateCharacterViewports
local SetBackground = ReplicatedStorage.RemoteEvents.SetBackground
local UpdatePartnerBackground = ReplicatedStorage.RemoteEvents.UpdatePartnerBackground

-- UI Elements
local Main = script.Parent
local StartButton = Main.Next
local StopButton = Main.Stop
local NextButton = Main.Next
local SendButton = Main.SendButton
local TextBox = Main.TextMessage
local ChatFrame = Main.ChatScrollframe
local OwnWebcam = Main.OwnWebcam.CharacterViewportFrame
local AnotherWebcam = Main.AnotherpersonWebcam.CharacterViewportFrame

-- Arka plan elementleri
local OwnBackground = Main.OwnWebcam.Background
local PartnerBackground = Main.AnotherpersonWebcam.Background
local BackgroundIdBox = Main.BackgroundId
local BackgroundButton = Main.BackgroundButton

-- Oyuncunun kendi arka planını sakla
local myBackgroundId = ""

-- Store rotation connections
local rotationConnections = {}

-- CHAT FUNCTIONS
local function AddChatMessage(msg)
	local label = Instance.new("TextLabel")
	label.Size = UDim2.new(1, -5, 0, 25)
	label.Text = msg
	label.TextColor3 = Color3.fromRGB(85, 255, 127)
	label.BackgroundTransparency = 1
	label.Font = Enum.Font.SourceSans
	label.TextSize = 20
	label.TextWrapped = true
	label.TextXAlignment = Enum.TextXAlignment.Left
	label.Parent = ChatFrame
	ChatFrame.CanvasSize = UDim2.new(0, 0, 0, ChatFrame.UIListLayout.AbsoluteContentSize.Y)
	ChatFrame.CanvasPosition = Vector2.new(0, ChatFrame.CanvasSize.Y.Offset)
end

local function playerChatMessage(msgs)
	local label = Instance.new("TextLabel")
	label.Size = UDim2.new(1, -5, 0, 25)
	label.Text = msgs
	label.TextColor3 = Color3.fromRGB(255, 126, 126)
	label.BackgroundTransparency = 1
	label.Font = Enum.Font.SourceSans
	label.TextSize = 20
	label.TextWrapped = true
	label.TextXAlignment = Enum.TextXAlignment.Left
	label.Parent = ChatFrame
	ChatFrame.CanvasSize = UDim2.new(0, 0, 0, ChatFrame.UIListLayout.AbsoluteContentSize.Y)
	ChatFrame.CanvasPosition = Vector2.new(0, ChatFrame.CanvasSize.Y.Offset)
end

-- Arka plan ayarlama
local function SetOwnBackground(imageId)
	if imageId and imageId ~= "" then
		local finalId = imageId
		if tonumber(imageId) then
			finalId = "rbxassetid://" .. imageId
		end
		OwnBackground.Image = finalId
		OwnBackground.BackgroundTransparency = 1
		OwnBackground.ImageTransparency = 0
		myBackgroundId = imageId
	else
		OwnBackground.Image = ""
		OwnBackground.BackgroundTransparency = 1
		myBackgroundId = ""
	end
end

local function HidePartnerBackground()
	PartnerBackground.Image = ""
	PartnerBackground.BackgroundTransparency = 1
end

local function ShowPartnerBackground(imageId)
	if imageId and imageId ~= "" then
		PartnerBackground.Image = "rbxassetid://" .. imageId
		PartnerBackground.BackgroundTransparency = 1
	else
		PartnerBackground.Image = ""
		PartnerBackground.BackgroundTransparency = 0
	end
end

-----------------------------------------------------------------------

-----------------------------------------------------------------------

local function DisplayCharacterInViewport(viewportFrame, character, viewportId)
	if not character or not viewportFrame then
		warn("[Viewport] geçersiz karakter veya viewportFrame")
		return
	end

	viewportFrame:ClearAllChildren()

	if rotationConnections[viewportId] then
		rotationConnections[viewportId]:Disconnect()
		rotationConnections[viewportId] = nil
	end

	local worldModel = Instance.new("WorldModel")
	worldModel.Parent = viewportFrame

	local cam = Instance.new("Camera")
	cam.Parent = viewportFrame
	viewportFrame.CurrentCamera = cam

	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid then
		warn("[Viewport] Humanoid bulunamadı.")
		return
	end

	local description = humanoid:GetAppliedDescription()
	local rigType = humanoid.RigType or Enum.HumanoidRigType.R15


	local dummy = Players:CreateHumanoidModelFromDescription(description, rigType)
	dummy.Name = "ViewportCharacter"
	dummy.Parent = worldModel

	-- PrimaryPart ayarı
	local root = dummy:FindFirstChild("HumanoidRootPart") or dummy:FindFirstChild("Head")
	if not root then
		warn("[Viewport] root part bulunamadı!")
		return
	end
	dummy.PrimaryPart = root

	-- Görünümü ortala
	dummy:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0, 0, 0)))

	-- Kamera kontrolü
	local rotationY = 180
	local rotationX = 0
	local zoomDistance = 5
	local minZoom, maxZoom = 2.5, 8
	local rotating = false
	local lastMousePos = Vector2.new()
	local sensitivity = 0.3

	viewportFrame.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton2 then
			rotating = true
			lastMousePos = input.Position
		end
	end)

	viewportFrame.InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton2 then
			rotating = false
		end
	end)

	viewportFrame.InputChanged:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseWheel then
			zoomDistance = math.clamp(zoomDistance - input.Position.Z * 0.5, minZoom, maxZoom)
		elseif input.UserInputType == Enum.UserInputType.MouseMovement and rotating then
			local delta = input.Position - lastMousePos
			lastMousePos = input.Position
			rotationY -= delta.X * sensitivity
			rotationX = math.clamp(rotationX - delta.Y * sensitivity, -25, 25)
		end
	end)

	local light = Instance.new("PointLight")
	light.Brightness = 2
	light.Range = 15
	light.Parent = cam

	rotationConnections[viewportId] = RunService.RenderStepped:Connect(function()
		if dummy and dummy.PrimaryPart then
			local radiansY = math.rad(rotationY)
			local radiansX = math.rad(rotationX)
			local offset = CFrame.Angles(0, radiansY, 0) * CFrame.Angles(radiansX, 0, 0)

			local focusPoint = dummy.PrimaryPart.Position + Vector3.new(0, 1.5, 0)
			local camPos = (dummy.PrimaryPart.CFrame * offset).Position + offset.LookVector * -zoomDistance
			cam.CFrame = CFrame.new(camPos, focusPoint)
		else
			if rotationConnections[viewportId] then
				rotationConnections[viewportId]:Disconnect()
				rotationConnections[viewportId] = nil
			end
		end
	end)
end



-----------------------------------------------------------------------

local function DisplayOwnCharacter()
	local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
	character:WaitForChild("Head")
	DisplayCharacterInViewport(OwnWebcam, character, "own")
end

DisplayOwnCharacter()

LocalPlayer.CharacterAdded:Connect(function(character)
	character:WaitForChild("Head")
	DisplayOwnCharacter()
end)

BackgroundButton.MouseButton1Click:Connect(function()
	local bgId = BackgroundIdBox.Text
	if bgId and bgId ~= "" then
		SetOwnBackground(bgId)
		SetBackground:FireServer(bgId)
		AddChatMessage("[System] Background updated!")
	end
end)

StartButton.MouseButton1Click:Connect(function()
	StartChat:FireServer(myBackgroundId)
	AddChatMessage("[System] Request in progress...")
	HidePartnerBackground()
end)

StopButton.MouseButton1Click:Connect(function()
	StopChat:FireServer()
	AddChatMessage("[System] The chat has ended.")
	AnotherWebcam:ClearAllChildren()
	if rotationConnections["partner"] then
		rotationConnections["partner"]:Disconnect()
		rotationConnections["partner"] = nil
	end
	HidePartnerBackground()
end)

NextButton.MouseButton1Click:Connect(function()
	NextChat:FireServer(myBackgroundId)
	AddChatMessage("[System] Looking for a new partner...")
	AnotherWebcam:ClearAllChildren()
	if rotationConnections["partner"] then
		rotationConnections["partner"]:Disconnect()
		rotationConnections["partner"] = nil
	end
	HidePartnerBackground()
end)

SendButton.MouseButton1Click:Connect(function()
	local text = TextBox.Text
	if text ~= "" then
		SendMessageEvent:FireServer(text)
		TextBox.Text = ""
	end
end)

UpdateCharacterViewports.OnClientEvent:Connect(function(partner, partnerBgId)
	AnotherWebcam:ClearAllChildren()
	if partner and partner.Character then
		local char = partner.Character or partner.CharacterAdded:Wait()
		DisplayCharacterInViewport(AnotherWebcam, char, "partner")
		AddChatMessage("[System] Connected: " .. partner.Name)
		ShowPartnerBackground(partnerBgId)
	else
		AddChatMessage("[System] Partner is Disconnected...")
		HidePartnerBackground()
		if rotationConnections["partner"] then
			rotationConnections["partner"]:Disconnect()
			rotationConnections["partner"] = nil
		end
		task.wait(0.5)
		NextChat:FireServer(myBackgroundId)
	end
end)

UpdatePartnerBackground.OnClientEvent:Connect(function(bgId)
	ShowPartnerBackground(bgId)
end)

SendMessageEvent.OnClientEvent:Connect(function(msgs)
	playerChatMessage(msgs)
end)

if not ChatFrame:FindFirstChild("UIListLayout") then
	local layout = Instance.new("UIListLayout")
	layout.Parent = ChatFrame
	layout.SortOrder = Enum.SortOrder.LayoutOrder
end

I can’t think of any obvious problems. I know in the past viewport frames didn’t support animations, but I recall they do now with the addition of WorldModels.

I would check that dummy has an Animator and try manually playing an animation on it. It seems like your code currently relies on CreateHumanoidModelFromDescription to set up the animation stuff.

The differences between studio and in game make me think there might be some kind of race condition going on. If something like this is happening, it probably has to do with building the humanoid model or when the animations try to start.

With your code here

local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
character:WaitForChild("Head")
DisplayCharacterInViewport(OwnWebcam, character, "own")

In live servers sometimes the CharacterAdded event only fires after your script runs, something like (“Head”) may not have loaded in fast enough so wrap it in a check like this

local function DisplayOwnCharacterSafe()
    local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
    if not character:FindFirstChild("Head") then
        character:WaitForChild("Head")
    end
    DisplayCharacterInViewport(OwnWebcam, character, "own")
end

Make sure none of these run on the server too as Viewport camera’s and Localplayer only works on the client.

ALSO, ensure that Players:CreateHumanoidModelFromDescription is on the client only and not handled somehow on the server