For some reason i keep getting an error which says this “LoadAnimation requires the Humanoid object to be a descendant of the game object” which is only thrown after i reset my character. Here is the code i am currently using
local Tool = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Animations = RS.Animations
local player = game:GetService("Players").LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animation = Humanoid:LoadAnimation(Animations.Curl)
local Debounce = false
i also tried adding this to wait for the character to be a descendant of game
while Character.Parent = nil do
Character.AncestoryChanged:Wait()
end
It stopped the error from appearing BUT, the animations didn’t play anymore which makes no sense. I tried printing character’s parent after the loop, it prints workspace but still doesn’t play any of the animations. I also tried loading the animations when the player equips the tool but that also throws the error. At this point i’m begging to lean towards thinking this is a roblox bug.
can I see the full script by chance? This will help me a lot more. Or you can just give me the context on how this is used. Like are you clicking then the animation plays?
Sure thing, So i load the animation as seen above. I play the animation when the player clicks
Tool.Activated:Connect(function()
if not Debounce then
Debounce = true
Animation:Play()
Animation.Stopped:Wait()
game.ReplicatedStorage.Remotes.ToolClick:InvokeServer()
Debounce = false
end
end)
Interesting, try this script in a different game because my code is almost the exact same as yours and it’s working just fine. (I rewrote your code into studio)
I have already made the game in TC and it is almost finished. Try storing the tool inside of replicated storage and cloning it to the player’s backpoack through a characteradded event on the server. Thats what i do and maybe that causes the problem. I have also been told by a friend that they had the same problem but, it went away after a day.
Okay, So I did some researching and I found this Post:
So, I applied a repeat until loop and to my surprise it worked.
this is what I have in my code:
local Tool = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Animations = RS.Animations
local player = game:GetService("Players").LocalPlayer
-- Noticed how I removed the "local Character = player.Character or player.CharacterAdded:Wait()"
repeat wait() until player.Character
local Humanoid = player.Character:WaitForChild("Humanoid")
local Animation = Humanoid:LoadAnimation(Animations.Curl)
local Debounce = false
That is very interesting at actually does work 0.0. I also dk why it works. Thanks a lot, If you do happen to find the reasoning behind it please do let me know