RunService.RenderStepped:Connect() is not working

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,
image
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

image

--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!

You probably wanted

local RunService = game:GetService("RunService")

Without the =, Lua sees a variable declaration (without a value, defaulting to nil) and an unrelated function call.

1 Like

oh i completely missed that, i put an = sign there now, im gonna test it and see if it works

it still didn’t work. It gave me the same error again

There’s no way it could throw the same error if RunService isn’t nil. Did you save your changes? Are you sure it’s the same error?

1 Like

Oh, apparently the changes didn’t save now it works. hehe my bad, thank you so much for your help though! I truly appreciate it!