Hi everyone!
I am having trouble with playing animations for my custom viewmodel I have made. The animations work fine if I put the viewmodel in Workspace, but they just wont play if they're in the camera. I also get no error messages in the console.
Here's the code for the view model:
--//Variables\\-- local cam = workspace.CurrentCamera local reps = game:GetService("ReplicatedStorage") local runs = game:GetService("RunService") local Magnum = reps:WaitForChild("Gun"):Clone() --//Connecting To The Camera\\-- for i,v in pairs (Magnum:GetChildren()) do if v:IsA("BasePart") then if v ~= Magnum.PrimaryPart then local weld = Instance.new("Weld") weld.Part0 = Magnum.PrimaryPart weld.Part1 = v weld.C0 = Magnum.PrimaryPart.CFrame:inverse() weld.C1 = v.CFrame:inverse() weld.Name = v.Name weld.Parent = Magnum.PrimaryPart end end end Magnum.Parent = cam --Viewmodel Position-- runs.RenderStepped:connect(function() Magnum:SetPrimaryPartCFrame(cam.CFrame*CFrame.new(0,-2,-2)) end)
I also made a separate script that goes into the viewmodel. Here's the code:
local Magnum = script.Parent local Hum = Magnum:WaitForChild("Humanoid") local Animations = Magnum:WaitForChild("Animations") --//Animations\\-- local Hold = Hum:LoadAnimation(Animations.Hold) local Idle = Hum:LoadAnimation(Animations.Idle) --Looped Animations-- Hold.Looped = true Idle.Looped = true Idle:Play()
Help is appreciated! Thanks!
Are you certain you rigged it correctly?