Hi! I'm a beginner scripter so I don't know how to script well, I tried making this but it doesn't work.
local anim = "AnAnimation"
while true do
anim:Play()
wait (0.99)
wait (0.99)
wait (0.99)
end
Any help would be helpful, thankiew! :3
Hi! I'm a beginner scripter so I don't know how to script well, I tried making this but it doesn't work.
local anim = "AnAnimation"
while true do
anim:Play()
wait (0.99)
wait (0.99)
wait (0.99)
end
Any help would be helpful, thankiew! :3
Run from a (Server) Script
local animation = script.Parent
animation.AnimationId = "rbxassetid://0"
local model = workspace:WaitForChild("Model")
local animPlayer = model.Humanoid:LoadAnimation(animation)
while true do
if script.Parent.TurnOff.Value == false then
animPlayer:Play()
wait(2)
else
wait()
end
end
Notes
Line 1: Make sure "script.Parent" is an Animation within ServerScriptService
Line 2: Set this to the id number of the animation (you MUST own it) If you set this value on the animation itself in Studio, you can also just remove this line.
Line 3: Set "Model" to the name of the NPC Model
Line 4: Change this location (workspace.Model.Humanoid) to the NPC you want to animate
Line 7: This is a BoolValue named "TurnOff" that when set to true will end the animation, it is parented under the Animation
Line 9: The number in the wait(#) should be the amount of time the animation runs for (default of 2)
Explanation: You cannot just play an Animation, it must be loaded into the NPC and played from an Animation Track, which is automatically made when you load the Animation into the Humanoid
(He used this for his answer) animation.AnimationId = "rbxassetid://0"
i have a question, why not "game.Workspace. ---" instead of "workspace. ----" ?
still confused..
@BuzzKill, you can write game.Workspace, its just that its quicker to use the single word workspace as its pre-defined by ROBLOX
I put the animation ServerScriptService right? and the script's parent is the nimation right? and theres a bool value parented in the animation right?
yep, also make sure the bool's name matches the one in the script (animation under ServerScriptService, bool and script both under animation)
Serpentine's answer will work, but there is a more efficient way to do it (in my opinion).
Like he said, you have to load it into a humanoid first and play the AnimationTrack object it creates.
local animation = Instance.new("Animation", script.Parent) -- create a new anim. object
animation.AnimationId = "rbxassetid://507766388" -- roblox idle anim
local model = workspace:WaitForChild("Dummy")
local AT = model.Humanoid:LoadAnimation(animation) -- load anim
while true do
AT:Play()
At.Stopped:wait() -- wait for track to stop playing, then play again
end
It utilizes the .Stopped event of the AnimationTrack, which waits for the animation to stop before proceeding.
at line 08 use AT not At
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Why are you using wait like that?
wait(2.97)
make the animation Loop