--Get the player
local character = Players.LocalPlayer.Character
if not character then
character = Players.LocalPlayer.CharacterAdded:Wait()
print("Waited")
end
character.Parent = workspace
local humanoid = character:WaitForChild("Humanoid")
repeat
wait()
print(character:IsDescendantOf(game), character.Parent)
if not character:IsDescendantOf(game) then
character.Parent = workspace
end
until humanoid:IsDescendantOf(game)
-- Create new 'Animation' instance
local hitAnimation = Instance.new("Animation")
-- Set its 'AnimationId' to the corresponding animation asset ID
hitAnimation.AnimationId = "rbxassetid://4704497461"
-- Load animation onto the humanoid
local hitAnimationTrack = humanoid:LoadAnimation(hitAnimation)
Whenever I reset a character, there will be a error when loading an animation, and it is because the character, or humanoid is not a descendant of game. I have already looked at quite a few stuff on this topic, but I don't think they work. Definitely not the one where you just wait, because it does not set any parent. Setting the parent, like in the script above, gives the error of infinite yield on right shoulder(the moving part) when animation is called(there is more code but this is the error part). Maybe I should ask how to fix infinite yield problem, or maybe there is another option. Thanks in advance. Also, this is a local script, in a weapon. Sorry if the way I copied my code is bad I don't know how to make it proper.

1 comment
An Infinite Yield is a warning the compiler throws when attempting to declare or reference an variable or Instance that doesn’t exist. Due to this, the compiler yields (waits) until it does; a warning is raised for the exception that it’ll wait forever, thus: ‘Infinite Yield Possible’