Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my veiwmodel animation not playing?

Asked by 5 years ago

I'm getting no errors. The animation works fine when I play it in the same model in the workplace.

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character
local cam = workspace.CurrentCamera
local reps = game:GetService("ReplicatedStorage")
local runs = game:GetService("RunService")
local gun = reps:WaitForChild("famas"):Clone()

for i,v in pairs (gun:GetChildren()) do
    if v:IsA("BasePart") or v:IsA("UnionOperation") then
        if v ~= gun.PrimaryPart then
            local weld = Instance.new("Weld")
            weld.Part0 = gun.PrimaryPart
            weld.Part1 = v
            weld.C0 = gun.PrimaryPart.CFrame:Inverse()
            weld.C1 = v.CFrame:Inverse()
            weld.Name = v.Name
            weld.Parent = gun.PrimaryPart
        end
    end
end

gun.Parent = cam
gun.Humanoid:LoadAnimation(gun.animations.idle):Play()

runs.RenderStepped:connect(function()
    gun:SetPrimaryPartCFrame(cam.CFrame*CFrame.new(0,-1.5,0))
    game:GetService("UserInputService").MouseIconEnabled = false
    plr.PlayerGui.hud.mouse.Position = UDim2.new(0, ((game.Players.LocalPlayer:GetMouse().X)-2), 0, ((game.Players.LocalPlayer:GetMouse().Y)-2))
end)
0
Line 14. CFrame:inverse() with lowercase i User#19524 175 — 5y
0
Inverse can be capital or lowercase. It works either way. smartlegomaniac 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Well I feel like an idiot. It was the welds keeping the animation from happening. I removed the welds from the parts connected to Motor6D and it works now.

Ad

Answer this question