So I have this script and it only plays two animations at the current time since that was all I have done, but say I wanted to play 3 or maybe four animations in a random order. How would I do this? Would I make a table of some sort?
local uis = game:GetService("UserInputService"); local plrs = game:GetService("Players"); local cooldown = false local leftp = false uis.InputBegan:Connect(function(obj, gp) if obj.KeyCode == Enum.KeyCode.Q and not gp then leftp = not(leftp) script.Damage.Disabled = false if cooldown then return end cooldown = true if leftp then local anim1 = plrs.LocalPlayer.Character.Humanoid:LoadAnimation(script.LPunch) anim1:Play() else local anim2 = plrs.LocalPlayer.Character.Humanoid:LoadAnimation(script.RPunch) anim2:Play() end wait(0.5) cooldown = false end end)
Hey TheCrimsonVortex,
local plrs = game:GetService("Players"); local uis = game:GetService("UserInputService"); local animations = {script.RPunch, script.LPunch, script.RKick, script.LKick} -- The animations go in here. function make_it_happen(obj, gp) if obj.KeyCode == Enum.KeyCode.Q and not gp then --[[ I will not be coding the basic things to make the animations happen, because you already know how to do that stuff, so I will just jump right into making a variable for the animations. --]] local anim = animations[math.random(#animations)]; -- This is the animation, you just load it. All I did was index a value from the animations table using a random number from 1 - the amount of values in the animations table. end end
~~ KingLoneCat