local player = game.Players.LocalPlayer local mouse = player:GetMouse() local hum = player.Character.Humanoid local attack = true script.Parent.Activated:Connect(function() local rpick = math.random(0,3) local hopethisworks = player.Character.Humanoid:LoadAnimation(script.Parent.Animation1 or script.Parent.Animation2 ) hopethisworks.Priority = Enum.AnimationPriority.Action hopethisworks:Play() script.Parent.Handle.Touched:Connect(function(hit) local player = game.Players.LocalPlayer local handle = script.Parent.Handle local hum = hit.Parent:FindFirstChild("Humanoid") if hum and attack == true then hum:TakeDamage(12) attack = false end end) wait(1) attack = true end)
You can define both animations into separate variables and put them into a table. Then, math.random() an animation from the table. After that, load and play the randomed animation.
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local hum = player.Character.Humanoid local attack = true --Defining variables for each animation. local anim1 = script.Parent.Animation1 local anim2 = script.Parent.Animation2 --Put the animations into a table. local anims = {anim1, anim2} script.Parent.Activated:Connect(function() --Pick an animation from the animation table. local pickedanim= anim[math.random(1,#anims)] local hopethisworks = player.Character.Humanoid:LoadAnimation(pickedanim) hopethisworks.Priority = Enum.AnimationPriority.Action hopethisworks:Play() script.Parent.Handle.Touched:Connect(function(hit) local player = game.Players.LocalPlayer local handle = script.Parent.Handle local hum = hit.Parent:FindFirstChild("Humanoid") if hum and attack == true then hum:TakeDamage(12) attack = false end end) wait(1) attack = true end)