I’m making a “simple” view model system where each tool has its own view model which are stored in a bank so that they can have their own rigs and animations. It’s just the animations don’t play, even the idle animation that is played right when a tool is equipped.
I added printing functions that print out the IsPlaying
property of the idle animation. The idle animation seems to be playing in the output but it isn’t visible.
This is the single local script for managing the view models:
-- MAIN INITIALIZATION PLACE
local me = script.Parent
local viewmodels = game.ReplicatedStorage.viewmodels -- THIS IS THE BANK FOR STORING VIEWMODELS
-- PLAYER RELATED STUFF
local plr = game.Players.LocalPlayer
local char = plr.Character
local cam = game.Workspace.CurrentCamera
-- RUNSERVICE GETTING THING
local runser = game:GetService("RunService")
-- MAIN ANIMATION STUFF
local hum = char:FindFirstChildWhichIsA("Humanoid")
local animer = hum:FindFirstChildWhichIsA("Animator")
-- DETECTS IF A TOOL HAS BEEN EQUIPPED
char.ChildAdded:Connect(function(child)
if child:IsA("Tool") then
local foundmodel = viewmodels:FindFirstChild(child.Name) -- LOOK FOR A VIEWMODEL FOR THE TOOL
local model = foundmodel:Clone() -- CLONE THE VIEWMODEL INTO WORKSPACE
model.Parent = game.Workspace
local head = model:FindFirstChild("head")
-- FINDING THE ANIMATIONS IN THE VIEWMODEL'S ANIMATION FOLDER
local anims = model:FindFirstChild("animations")
local anim1 = anims:FindFirstChild("idle")
local anim2 = anims:FindFirstChild("use")
-- CREATE ANIMATION TRACKS
local idle = animer:LoadAnimation(anim1)
local use = animer:LoadAnimation(anim2)
idle:Play() -- PLAY THE IDLE ANIMATION (DOESN'T WORK FOR SOME REASON)
local run = runser.RenderStepped:Connect(function()
head.CFrame = cam.CFrame -- CASUAL VIEWMODEL STUFF
end)
child.Activated:Connect(function()
use:Play() -- PLAY THE USING ANIMATION (ALSO DOESN'T WORK FOR SOME REASON)
end)
-- DESTROY THE VIEWMODEL AND STOP THE RUNSERVICE STUFF WHEN THE TOOL IS UNEQUIPPED.
char.ChildRemoved:Connect(function(removed)
if removed:IsA("Tool") then
run:Disconnect()
model:Destroy()
end
end)
end
end)