hey so im trying to make a viewmodel for an fps game and i came across a problem. now first everything worked perfectly when i tried to parent the viewmodel to the camera and it following it. so i tried to add an animation and when i did nothing happened, so i tried to add a print statement and the script printed that the animation was playing even though on my visual it wasnt.
script:
local camera = workspace.CurrentCamera
local viewmodel = game.ReplicatedStorage:FindFirstChild("ViewModel")
local animationId = "rbxassetid://96784505884831"
if not viewmodel then return end
viewmodel = viewmodel:Clone()
viewmodel.Parent = camera
local arms = viewmodel:FindFirstChild("Arms")
if arms then
viewmodel.PrimaryPart = arms
else
return
end
viewmodel.PrimaryPart.Anchored = true
viewmodel:SetPrimaryPartCFrame(camera.CFrame * CFrame.new(0, -1, -2.5))
game:GetService("RunService").RenderStepped:Connect(function()
if viewmodel and viewmodel.PrimaryPart then
viewmodel:SetPrimaryPartCFrame(camera.CFrame * CFrame.new(0, -1, -2.5))
end
end)
local head = player.Character and player.Character:FindFirstChild("Head")
if head then
head.Transparency = 1
end
local animController = Instance.new("AnimationController")
animController.Parent = viewmodel
local animator = Instance.new("Animator")
animator.Parent = animController
local animation = Instance.new("Animation")
animation.AnimationId = animationId
local loadedAnim = animator:LoadAnimation(animation)
loadedAnim.Looped = true
loadedAnim:Play()```
if anyone could help me i'd really appreciate it. thanks!