"Not a Valid Member of" error

Yo So I’m trying to make a basic sprint animation and am trying to check if the animation is working before I move on to binding it to a key, however whenever I load up the script I get the error “not a valid member of LocalScript “Workspace.Narcelinee.AnimationHandler”” I never had this issue before so I’m confused, I also wanna know what the error means and how you can fix it for future reference

This is all the script is with ShindenSprint being an animation Object with an assetid put itno it

local sprintAnimation = script.ShindenSprint
wait(1)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char.Humanoid

local sprintAnimationTrack = humanoid:LoadAnimation(sprintAnimation)


while true do
	sprintAnimation:Play()
end
5 Likes

the not a valid member means that it does not exist in “Workspace.Narcelinee.AnimationHandler” so you need to check if its actually there

2 Likes

ok but like its in the StarterPlayerScripts folder which is in workspace, i tried taking the local script out of this folder and putting it in workspace and there were no errors happening but the script wasnt working

1 Like

local scripts dont work outside of starterplayerscripts, startercharacterscripts, starterGui and starterpack. I recommend putting your script in startercharacterscripts

1 Like

ya thats what I thought, its in startercharacterscripts but I still get an error, so im confused since startercharacterscripts is in the workspace already cuz if i try to put starterplayer in workspace it doesnt do anything

1 Like

can u give me a screenshot of where the local script and the animation is and also a screenshot of the error


1 Like

Try to use :WaitForChild() maybe it didnt load in or sum

1 Like

tried already, the wait script would do that for me anyways

can u do a screen shot of whats inside of the animation handler

Try to put the code in StarterPlayerScripts instead

image

image

then this error shows up

Ooh i see the error:

local sprintAnimation = script.ShindenSprint
wait(1)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char.Humanoid

local sprintAnimationTrack = humanoid:LoadAnimation(sprintAnimation)


while true do
	sprintAnimationTrack:Play() --Here u used sprintAnimation 
end

I recommend not to loop it like that

error still happens, and the loop is temporary to test if the animation stuff even works its not forever

Oh my bad
U needed to use

local animator = humanoid:FindFirstChildOfClass("Animator")

So:

local sprintAnimation = script.ShindenSprint
wait(1)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char.Humanoid
local animator = humanoid:FindFirstChildOfClass("Animator")
local sprintAnimationTrack = animator:LoadAnimation(sprintAnimation)


while true do
	sprintAnimationTrack:Play() --Here u used sprintAnimation 
end

the same error still occurs, im confused asf is this a new error or something i never had this once like a year ago

U sure that u copied my code correct cause that should work

local sprintAnimation = script.ShindenSprint
wait(1)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char.Humanoid

local sprintAnimationTrack = humanoid:LoadAnimation(sprintAnimation)

sprintAnimationTrack.Looped = true
sprintAnimationTrack:Play()

this should work

I told u needed to use :WaitForChild() it worked for me like this

local sprintAnimation = script:WaitForChild("ShindenSprint")
wait(1)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char.Humanoid
local animator = humanoid:FindFirstChildOfClass("Animator")
local sprintAnimationTrack = animator:LoadAnimation(sprintAnimation)


while true do
	sprintAnimationTrack:Play() --Here u used sprintAnimation 
end