So I’m making a weapon fighting game and I need a little bit of help on something and that problem is making a rng animation tool or random animation selector and I need to apply this on a sword I also have the 3 animations all ready and the sword the only thing I need is to get the rng thing
Yes I did try to find any solutions to this and I did find 1 but that didn’t work but I will still search to find more after I’m done making this post
Also if someone finds a solution to that I will be very very happy and glad
You could just use math.random or something
like
local which = math.random(1,3)
if which == 1 then
anim1:Play()
elseif which == 2 then
anim2:Play()
else
anim3:Play()
end
idk if this is the best method
Assuming all three AnimationTrack
s are loaded into an array, you should do:
AnimationTracks[math.random(#AnimationTracks)]:Play()
If that has not been done,
local function LoadAnimations()
local Player = Players.LocalPlayer
local Character = Player.Character
if Character == nil or Character.Parent == nil then
Character = Player.CharacterAdded:Wait()
end
local Animations = --[[Path.to.Animations]]:GetChildren()
local Animator = Character:WaitForChild("Humanoid")
:WaitForChild("Animator")
for Index, Animation in ipairs(Animations) do
Animations[Index] = Animator:LoadAnimation(Animation)
end
return Animations
end
The above function can be reorganized if relative information is already present.
good to know
thanks, i am going to use that a lot