How do I make codes for animations. I'm trying to make an animation for my dancing game and i know how to make animations but I'm having a hard time scripting them in my game. Do you know how to script them into games?
I'm not the best at scripting, so my answer may be wrong, but as long as you have the ID of the animations you made, this script should (hopefully) work for you.
local player = game.Players.LocalPlayer local Mouse = player:GetMouse() local Char = player.Character local Humanoid = Char:WaitForChild("Humanoid") local animations = {1877306614,1877291193,01895620990} --Change the numbers into the IDs of your animations local function Animation(plr) local animation = Instance.new("Animation") local picked = math.random(1, #animations) animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked] local animTrack = Humanoid:LoadAnimation(animation) animTrack:Play() end Mouse.Button1Down:connect(function() print("PlayAnimation") Animation() end)
This script should play one of your animations at random when you click. You might want to add a debounce script or something like that to prevent others from playing the animations too quickly.