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

Using single animations?

Asked by 8 years ago

I am trying to make an NPC that has a typing animation. No, I am not making a custom animations-type thing. I want to make the animation loop, when the game starts. Just a single animation. I looked over the wiki and couldnt find anything (yes, I tried the Animations section. Didnt work). The animation is: https://www.roblox.com/typing-item?id=420291785 . I cannot seem to find the issue. Do I need a script to start it, or where would I put the animation?

0
Did you make the animation? yoshi8080 445 — 8y
0
^ hes the owner of the animation Teeter11 281 — 8y
0
also what is even your problem? you just say you want the animation to loop but i dont know what your problem is Teeter11 281 — 8y
0
It just does not work. The animation never starts. How would i make the animation start (I have it set to loop) when the game starts? The_Sink 77 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

I am assuming here that your NPC is pretty close to a player, is in workspace, and has a humanoid. I think this may work :D

NPC = workspace.NPC
repeat wait() until NPC ~= nil
local human = NPC:WaitForChild("Humanoid")
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/Asset?ID=420291785"
local animControl = Instance.new("AnimationController")
local animTrack = animControl:LoadAnimation(anim)

while true do
    animTrack:Play()
    wait(animTrack.Length)
end
0
Nope. Didnt work for me. There were no errors in the log, but the animation just did not run. The_Sink 77 — 8y
Ad
Log in to vote
0
Answered by
yoshi8080 445 Moderation Voter
8 years ago

I made this quick little thing, hope this works. Place this script in the NPC and place the animation in the script like for example "NPC.Script.Animation"

    function PlayAnimation()

    local Humanoid = script.Parent:WaitForChild('Humanoid') -- Waits for humanoid in the NPC
    local Animation = Humanoid:LoadAnimation(script.Animation) -- name Animation to what you named your animation.
        wait(.3)
            Animation:Play() -- Plays your animation
        end

game.Players.PlayerAdded:connect(PlayAnimation)
0
Still didn't work :/ The_Sink 77 — 8y
0
Weird, I used this script and it works 100% for me. yoshi8080 445 — 8y

Answer this question