Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I fix this simple animation issue for a player?(I wrote an error from the console)

I will explain my script briefly. This script is normal script. It is located in the door. The door has a "Handle" with a click detector in it. This is not the point. Let's move on to the second part of the script. The script detects if the player is in the team. If so, the door stops. is de-anchored and the player has to play the animation, the problem is that the animation does not work.

To help you troubleshoot the problem, this is the only error underlined in yellow on the console. " ? Infinite yield possible on 'Workspace.KotyOceloty:WaitForChild("humanoid")' (x2) - Studio"

function Open(player)
	if player.Team == game.Teams["DOR Members"] then
		if opened == false then
			opened = true
			for i = 1, 10 do
				script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(9), 0))
				wait()
			end
		else
			opened = false
			for i = 1, 10 do
				script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-9), 0))
				wait()
			end
		end
	end
	
	if player.Team == game.Teams.Interpol then
		local copy = game.ReplicatedStorage.Door:Clone()
		local remain = game.ReplicatedStorage.CopyDoor:Clone()
		--animation script start
		local animation = Instance.new("Animation")
		animation.AnimationId = "http://www.roblox.com/Asset?ID="..8293367949
		--here the console shows I have a problem.(down)
		local loadedAnimation = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
		game.Workspace["Fbi open up"]:Play()
		wait(2.011)
		loadedAnimation:Play()
		--play animation
		wait(0.5)
		script.Parent:Destroy()
		remain.Parent = game.Workspace
		remain.Anchored = false
		--makes door fall from upstairs and plays sound
		game.Workspace["Wood Breaking"]:Play()
	end
		
	end

if someone still does not understand, it has what interests me written in the script. I am asking for a quick answer.

2 comments

0

This is not an error but warning, :WaitForChild waits for child to exist, if the child won't ever exist it will just wait forever, this is called infinite yield, you possibly wrote "humanoid" wrong since the "h" should be uppercase -> "Humanoid", this is not the script that shows the warning though.

0

I did everything good but nothing works

1 answer

There is a possibility that there is more than one model named as your Username, and in my opinion, there is also a better way to get the player's character and is from player.Character.

So your line would look like this:
Player.Character:FindFirstChild('Humanoid'):LoadAnimation(animation)

2 comments

0

should this zero be there?

0

no, it was a typo, it should be ")", sorry!!

This discussion is preserved as it was. New answers, comments, and votes are closed.