Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my veiwmodel animation not playing?

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)

2 comments

0

Line 14. CFrame:inverse() with lowercase i

0

Inverse can be capital or lowercase. It works either way.

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.