Viewport Frame broken after applying bundle

  1. I want my viewport frame to continue showing the player even when a bundle is added to the player.

  2. When I add a bundle to the player, the viewport frame is broken, and doesn’t show anything(Ignore bad UI, it’s just a placeholder): Video of Issue
    Viewport frame is the right half of screen.

  3. I added a loop to the viewport frame to continuously update the frame, it worked, but the frame was constantly glitchy and looked bad.

Code
-- Server Script, adds bundle to player
local bundleDetails = game:GetService("AssetService"):GetBundleDetailsAsync(952)
local bundleId = 0
for _,item in pairs(bundleDetails.Items) do
	if item.Type == "UserOutfit" then
		bundleId = item.Id
		break
	end
end
local descr = game.Players:GetHumanoidDescriptionFromOutfitId(bundleId)

player.Character.Humanoid:ApplyDescription(descr)
--Local Script, the viewport frame is edited here
local viewPortFrame = script.Parent
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
char.Archivable = true

local newCamera = Instance.new("Camera")
newCamera.Parent = viewPortFrame
viewPortFrame.CurrentCamera = newCamera

local clonedChar
game:GetService("RunService").RenderStepped:Connect(function()
	if clonedChar then clonedChar:Destroy() end
	clonedChar = char:Clone()

	local hrp = clonedChar:WaitForChild("HumanoidRootPart")

	newCamera.CFrame = CFrame.new(hrp.Position + (hrp.CFrame.LookVector * 6) + Vector3.new(0,2,0) + (hrp.CFrame.RightVector * 2), hrp.Position) 
	
	clonedChar.Parent = viewPortFrame
end)

The issue here is that the viewport frame is only capturing the player’s character once, and since the ApplyDescription function is changing the character’s appearance, it breaks the link between the character and the viewport frame. One solution to this is to continuously update the viewport frame with the new character appearance, instead of capturing it once. Here’s an updated version of the local script that should fix the issue:

local viewPortFrame = script.Parent
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
char.Archivable = true

local newCamera = Instance.new("Camera")
newCamera.Parent = viewPortFrame
viewPortFrame.CurrentCamera = newCamera

local clonedChar
game:GetService("RunService").RenderStepped:Connect(function()
    if clonedChar then clonedChar:Destroy() end
    clonedChar = char:Clone()
    clonedChar.Archivable = false
    clonedChar.Humanoid:ApplyDescription(char.Humanoid:GetAppliedDescription())

    local hrp = clonedChar:WaitForChild("HumanoidRootPart")

    newCamera.CFrame = CFrame.new(hrp.Position + (hrp.CFrame.LookVector * 6) + Vector3.new(0,2,0) + (hrp.CFrame.RightVector * 2), hrp.Position) 
    
    clonedChar.Parent = viewPortFrame
end)

In this version, we continuously clone the player’s character, apply its current appearance to the clone, and then update the viewport frame with the clone’s position and appearance. This should ensure that the viewport frame always displays the player correctly, even after adding a bundle.

The line clonedChar.Humanoid:ApplyDescription(char.Humanoid:GetAppliedDescription()) spams my output with a Humanoid::ApplyDescription() DataModel was not available error.

maybe its because the code runs even if the players character hasnt loaded yet?

I added a wait, but the issue still occurs, so it’s calling something incorrectly.

A wait(number) or a player.CharacterAdded wait?

There is a player.CharacterAdded wait in the first few lines of the script, and I added a separate later in the script, but neither worked.

This issue only occurs with some bundles apparently. Changed the bundle, and issue was solved… possible Roblox bug?

Either way, I’ll just rely on the working bundle for now.

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