So i try to make player animate when taken damage.
local dmg = true
local ready = true
local animation =(2488441216)
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Humanoid and dmg == true and ready then
local hum = hit.Parent.Humanoid
hum:TakeDamage(10)
local track = hum:LoadAnimation(animation)
track:Play()
dmg = false
wait(1)
dmg = true
end
end)
How to fix this?
Error:Unable to cast value to Object

12 comments
Addition the script.Parent is script and Script.Parent.Parent is ServerScriptService. btw how am i going to use :FindFirstChildOfClass() or :FindFirstChild()
no for like checking if a humanoid exists
is part line 3 and 4 an error?
oops i forgot to add that in lol
hold up'
Ok
ok done
New error. FindFirstChild is not a valid member of a model.
I replace it with :FindFirstChild but the Unable to cast value to Object still poping up
o wait
you need to make the Instance "Animation" to use :LoadAnimation()
then define the animation in the arguments and set the animation ID