How do you scale welds based on size?

hello everyone. today, i’m just curious how i could scale a weld’s c0 and c1 properties based on a scale. confused? let me explain…

i am creating a viewmodel. i am trying to make it not clip through walls, and viewport frames are so easily noticeable and have an unavoidable one-pixel outline. instead, i am using the method discussed here to create the illusion of no viewmodel clipping. just one issue; because i am using a system which requires the tool to be inside of the character (and not the viewmodel) at all times, i need to also scale it along with the viewmodel, meaning that roblox does not automatically handle the weld adjustments!

my little short code snippet:

local scale = 0.2
local offset = Vector3.new(0, -2, 0)
runservice:BindToRenderStep("Viewmodel", Enum.RenderPriority.Camera.Value, function()
	update_animations()
	
	local tool = char:FindFirstChildOfClass("Tool")
	if tool then
		tool:ScaleTo(0.2)
	end
	
	viewmodel:ScaleTo(scale)
	viewmodel:PivotTo(camera.CFrame * CFrame.new(offset * scale))
end)

pretty clear issue here. any help would be greatly appreciated! thanks for reading.

fortunately, i found a solution! was struggling with this for an hour before realising i can use the exact same system i used for the viewmodel to make this work :upside_down_face:

so i have this code:

char.DescendantAdded:Connect(function(weld)
	if weld:IsA("Motor6D") and weld.Name == "RightGrip" then
		weld.Part0 = viewmodel[weld.Part0.Name]
	end
end)

the solution?

local c0 = weld.C0
weld.C0 = CFrame.new(c0.Position * scale) * CFrame.Angles(c0.Rotation:ToOrientation())

i feel very silly now. sorry for wasting anybody’s time reading this xD

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