Make viewmodel point towards mouse.hit

how can i make my viewmodel point towards mouse.hit

if you look at this picture the spray particles clearly aren’t hitting the part

this is my code

connection = runservice.RenderStepped:Connect(function(dt)
		local Delta = game.UserInputService:GetMouseDelta()
		SwaySpring:shove(Vector3.new(-Delta.X/100, Delta.Y/150, 0))
		BobSpring:shove(Vector3.new(Bob(5), Bob(10), Bob(5)) / 10 * (Character.PrimaryPart.Velocity.Magnitude) / 10)
		local handssway = SwaySpring:update(dt)
		local handsbob = BobSpring:update(dt)
		local fulloffset = workspace.CurrentCamera.CFrame * CFrame.new(3,-1,-4)*CFrame.Angles(math.rad(90),math.rad(0),math.rad(-90))
		local ultrafulloffset = fulloffset * CFrame.new(0, handssway.X, handssway.Y) * CFrame.new(0, handsbob.X, handssway.Y)
		paintgun:PivotTo(ultrafulloffset)
	end)
1 Like

You can cast a ray from the tip to the mouse target and align the spray particles to the direction.

1 Like
local viewmodel : Model = ... --PATH HERE
local mouse = game.Players.LocalPlayer:GetMouse()

local function event()
    local targetPosition = mouse.Hit.Position
    local origin = viewmodel:GetPivot().Position
    local lookCFrame = CFrame.lookAt(origin, targetPosition)
    viewmodel:PivotTo(lookCFrame)
end

event()