So I’m currently trying to add animations to my pickaxes, and for some reason, the runservice.RenderStepped
isn’t working. It will give me this error,
I used a local script for the pickaxe animations but I don’t know if I need to use a normal script, so I tried to do that as well but it didn’t work either. I don’t understand RunService as much, so I read RunService.RenderStepped but didn’t give me much help in trying to fix.
Here’s what the script looks like and where it’s located
--Services
local player = game:GetService("Players").LocalPlayer
local RunService game:GetService("RunService")
--Variables
local animations = {script.Parent.Animations.Idle, --Idle Animation
script.Parent.Animations.Walk, --Walking Animation
script.Parent.Animations.Run, --Sprinting Animation
script.Parent.Animations.Mine --Mining Animation
}
local loadedAnimations = {}
local tool = script.Parent
local hum = player.Character:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
--Functions
function Update()
if not loadedAnimations[2] then
loadedAnimations[2] = animator:LoadAnimation(animations[2])
end
if hum.Health > 0 and hum.MoveDirection.Magnitude ~= 0 then
if not loadedAnimations[2].IsPlaying then
loadedAnimations[2]:Play()
end
else
if loadedAnimations[2].IsPlaying then
loadedAnimations[2]:Stop()
end
end
end
--Set Up
RunService.RenderStepped:Connect(Update)
tool.Equipped:Connect(function(mouse)
if not loadedAnimations[1] then
loadedAnimations[1] = animator:LoadAnimation(animations[1])
end
loadedAnimations[1]:Play()
end)
tool.Unequipped:Connect(function()
loadedAnimations[1]:Stop()
end)
Any help is appreciated!