Trying to attach the viewmodel to the player’s camera, and most gun kits and games have it just perfectly on the camera?
im wondering how they do this as im just setting the pivot of the viewmodel to the currentcam’s cframe which isnt working too well
Code that i forgot to add
-- Wait()
repeat task.wait() until game:GetService("Players").LocalPlayer.Character
-- Variables
local Player = game:GetService("Players")["LocalPlayer"]
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local HoldAnim = Instance.new("Animation"); HoldAnim.AnimationId = "rbxassetid://10469949936"
local ShootAnim = nil
local ViewModel = game.ReplicatedStorage.AkViewmodel:Clone(); ViewModel.Parent = game.Workspace.Camera
local Animator = ViewModel:WaitForChild('Humanoid').Animator
local Locked = false
local LockedConnection = nil
-- Functions
local function LockToCamera()
if Locked then return end
Locked = true
coroutine.resume(coroutine.create(function()
local S, E = pcall(function()
ViewModel:WaitForChild("CameraBone")
LockedConnection = RunService.Heartbeat:Connect(function()
ViewModel:PivotTo(workspace.CurrentCamera)
end)
end)
end))
end
local function Unlock()
if Locked then
Locked = false
LockedConnection:Disconnect()
end
end
-- Main
ViewModel.CameraBone.Transparency = 1
Animator:LoadAnimation(HoldAnim):Play()
LockToCamera()