Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I cant weld my viemodel to my camera, Why? (I am dumb..)

local loadout = {
	
	--DEFAULT LOADOUT
	Primary = "M4";
	Secondary = "M9";
	Meele = "Knife";
	
}

weaponPosition = CFrame.new(2,-2,2)
local primary = guns[loadout.Primary]:Clone()
run.RenderStepped:Connect(function()
	primary:SetPrimaryPartCFrame(cam.CFrame * weaponPosition)
end)
primary.Parent = cam	

Everytime I play the game it just wont get welded to the camera. I see nothing. I have a folder with guns, the guns have the same name as the names in the loadout table.

1 answer

✓ Accepted answer

The model is behind the camera. You offset cam.CFrame by weaponPosition which moves it forwards 2 studs in relation to cam.CFrame. Negate the value and you should be good to go.

Another issue you might face is the model seeming to lag one frame behind. That'd be because the camera is updated after the viewmodel. If so happens, take advantage of BindToRenderStep's priority parameter and set it to anything above Enum.RenderPriority.Camera.Value.

1 comment

0

Yeah I found it out myself later. The root part was facing back so the weapon was behind me too. Rip.

This discussion is preserved as it was. New answers, comments, and votes are closed.