Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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.

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. imKirda 4491 — 2y
0
I did everything good but nothing works KotyOceloty 25 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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)

0
should this zero be there? KotyOceloty 25 — 2y
0
no, it was a typo, it should be ")", sorry!! Sarturex857 109 — 2y
Ad

Answer this question