My Viewmodel wont center to the screen

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want the aim to center to the screen

  2. What is the issue? Include screenshots / videos if possible!
    https://gyazo.com/a2d08b66fe6fd84949351999121c28ab
    When I aim far away the sight doesn’t align with enemy

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I stopped the animation, used CFrame.new() to change position for viewmodel, I’ve been looking everywhere since these are the only solutions I could think of but I found nothing

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!


local Gun = script.Parent
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Character = workspace:WaitForChild(Player.Name)
local SpringModule = require(game.ReplicatedStorage.SpringModule)
local RunService = game:GetService("RunService")
local Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator")
local Camera = workspace.CurrentCamera
local ViewModel = Camera:WaitForChild("ViewModel")
local Offset = Character:WaitForChild("ViewModel"):WaitForChild("Offset")
local Handle = Gun.Handle
local AimPart = Handle.AimPart

local ADSHeld = false
Mouse.Button2Down:Connect(function()
	ADSHeld = true
end)
Mouse.Button2Up:Connect(function()
	ADSHeld = false
end)

local Animation = Instance.new("Animation", Gun)
Animation.AnimationId = "rbxassetid://9066567733"
Animation = Animator:LoadAnimation(Animation)
Animation:SetAttribute("ViewModelAnimation", true)

RunService.RenderStepped:Connect(function(dl)
	local HandleTransform = ViewModel:GetPrimaryPartCFrame():ToObjectSpace(Handle.CFrame) --Starts viewmodel.PrimaryCFrame as 0,0,0 then adds the handle.cframe distance ex. Distance 1, 1, 1
	local OriginalTransform = HandleTransform * HandleTransform:Inverse()
	local AimTransform = AimPart.CFrame:ToObjectSpace(Handle.CFrame) * HandleTransform:Inverse()
	
	if ADSHeld then
		
		Offset.Value = AimTransform
		game:GetService("UserInputService").MouseIconEnabled = false
		
	else
		
		Offset.Value = OriginalTransform
		Mouse.Icon = "rbxassetid://7262331135"
		game:GetService("UserInputService").MouseIconEnabled = true

	end
	
end)
Gun.Equipped:Connect(function()
	Animation:Play()
end)

Gun.Unequipped:Connect(function()
	Animation:Stop()
end)


I noticed I am working in my gun script when I should have been looking into my Viewmodel script. Will update when I get home and have looked into that