i followed this tutorial of how to make a view model but its using run service so if i were to make an animation it would glitch out from the run service loop right?
- How do i animate a view model
local swayCF = CFrame.new()
RunService.RenderStepped:Connect(function()
if player.Character.Humanoid.Health == 0 then
if workspace.Camera:FindFirstChild("ViewModel") ~= nil then
workspace.Camera.ViewModel:Destroy()
end
end
if equipped then
if workspace.Camera:FindFirstChild("ViewModel") ~= nil then
workspace.Camera.ViewModel:SetPrimaryPartCFrame(workspace.Camera.CFrame)
for i, v in workspace.Camera.ViewModel:GetChildren() do
if not v:IsA("BasePart") then continue end
v.CanCollide = false
end
end
local mouseDelta = UserInputService:GetMouseDelta()/script.Parent:GetAttribute("SwayModifier")
local swayX = math.clamp(mouseDelta.X, -0.2, 0.2)
local swayY = math.clamp(mouseDelta.Y, -0.2, 0.2)
swayCF = swayCF:Lerp(CFrame.new(swayX, swayY, 0), .3)
workspace.Camera.ViewModel:SetPrimaryPartCFrame(workspace.Camera.CFrame * swayCF)
end
end)