WeldConstraint not working inside of a ViewportFrame

I’m trying to make it so that when you press F a lantern shows up in a ViewportFrame, but for some reason if I try to weld the lantern to the fake arm it just doesnt move.

I was using this:

lantern = game.ReplicatedStorage.Objects.Lantern:Clone()
lantern.Parent = viewport
local weld = Instance.new("WeldConstraint")
weld.Parent = lantern
weld.Part0 = lantern
weld.Part1 = arm
lantern.CFrame = arm.CFrame * CFrame.new(0,-1.125,0)
local tween = game:GetService("TweenService"):Create(arm,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false),{CFrame = cam.CFrame * CFrame.new(1.25,-0.75,-1.5) * CFrame.Angles(math.rad(-60),math.rad(-10),math.rad(30))})
tween:Play()
tween.Completed:Wait()

The result was the arm showing up, but the lantern didnt.

Later I tried this:

lantern = game.ReplicatedStorage.Objects.Lantern:Clone()
lantern.Parent = viewport
lantern.CFrame = cam.CFrame * CFrame.new(1.25,-0.75,-1.5)

And the lantern showed up, meaning that the WeldConstraint didn’t work

So how would I tween the lantern along with the arm without having to use a WeldConstraint?

Why not make a normal view model? With a viewport frame the lighting isnt the same as the scene.

I put the light in the workspace

Yeah, but the viewport frame is gonna be the same brightness no matter where you go.

You’re right. I will check it out

So, how did it go? If you got something your okay with, please set a post solution so people can see that it’s done.

I’m currently having a different issue. I want to use an AlignPosition object to constantly move the arm in front of the camera, but for some reason the position of it doesnt change.

game:GetService("RunService").RenderStepped:Connect(function()
	if not lanternequipped then
		bodypos.Position = Vector3.new(cam.CFrame.Position + Vector3.new(1.25,-3,-1.5))	
		bodygyro.CFrame = CFrame.Angles(math.rad(-80),math.rad(-30),math.rad(60))	
		print("lantern unequipped")
		print(bodypos.Position)
	else
		bodypos.Position = Vector3.new(cam.CFrame.Position + Vector3.new(1.25,-0.75,-1.5))
		bodygyro.CFrame = CFrame.Angles(math.rad(-60),math.rad(-10),math.rad(30))
		print("lantern equipped")	
		print(bodypos.Position)
	end
end)

image

I tried the exact same thing without a script on the workspace and worked perfectly fine. I’m assuming its a problem on the client or something related

ViewportFrames do not have physics (i.e. things that rely on velocity to move other things, like AlignPosition or AlignOrientation, or any of the body movers for that matter), the closest you have is putting everything under a WorldModel under the ViewportFrame, but that only lets you use joints (animatable Motor6Ds, welds etc).


Speaking of WorldModels, that is exactly what you need to use WeldConstraints in ViewportFrames.

EDIT 19/07/2025: Got Popular Link badge from this

4 Likes

Alright so it took me a couple hours and I completely had to remake everything, not really a solution because what I mentioned isn’t possible with a ViewportFrame, but what you said was a great alternative. I’m gonna mark it as a solution.

1 Like

To explain ‘ViewportModel’ instances don’t support physics (this includes ‘JointInstance’ instances, i.e; ‘Weld’, ‘Glue’, ‘Snap’ etc.). ‘WorldModel’ instances are required in order for physics to be simulated inside ‘ViewportModel’ instances.

3 Likes

i had the same issue
i put the ‘ViewportModel’ in a ‘WorldModel’ that is in a ‘viewportFrame’, and for some reason, ‘JointInstance’ instances works

1 Like

I wish I had known that 2 years ago. But as the “solution” said, the light from the viewport won’t affect the workspace so yeah it’s not really the optimal solution

1 Like