When the function is called it runs all the way through with no errors.
But animation is never played
(The animations are the defult roblox ones)
(Tried local and server scripts in StaterCharacterScripts)
local AnimationOne = Instance.new("Animation")
AnimationOne.AnimationId = "rbxassetid://130018893"
local AnimationTwo= Instance.new("Animation")
AnimationTwo.AnimationId = "rbxassetid://132546839"
local AnimationThree = Instance.new("Animation")
AnimationThree.AnimationId = "rbxassetid://132546884"
local Animations = {AnimationOne, AnimationTwo, AnimationThree}
local AnimationTrack
local Dancing = false
local Humanoid = script.Parent:WaitForChild('Humanoid')
local Animator = Humanoid:WaitForChild("Animator")
function Dance()
Dancing = true
AnimationTrack = Animator:LoadAnimation(Animations[math.random(1,#Animations)]) -- this will return an AnimationTrack instance that can be played
AnimationTrack:Play()
end
Dance()
The problem might be that you didn’t set a parent for the new instance ( the animations parent = nil )
I don’t think it works like that, BUT I could def be wrong and It works for some whack reason.
Maybe try setting the parent to ServerScriptService or the humanoid
Okay this fixed it, turns out i was using R6 animations Whoops.
Another problem though is that when it plays and the player moves the animation stops, which is fine
although im trying to get it so they keep dancing after they stop again.
So im using this
while true do
repeat wait() until game.Workspace.Players:WaitForChild(game.Players:GetPlayerFromCharacter(script.Parent).Name).InDance.Value == true
Dance()
repeat wait() until AnimationTrack.IsPlaying == false
end
But i dont think when the animation is cancelled by moving that IsPlaying == false. its still playing but not showing (I think)
So it works imediatly when InDance == true but when he moves he stops dancing and because IsPlaying is still equal to true for some reason he doesnt continue his lil dance.
All i really need is a way to detect if the animations been cancelled without making a load of functions to tell if WASD is being pressed
Its when a player stands in a region. But don’t worry I’ve got that code sorted
InDance == True when he is in Region
and InDance == false when hes out of region