#how to change a player's animations based on their character in a battlegrounds game

1 messages · Page 1 of 1 (latest)

azure lance
#

im making a battlegrounds game and each character will have different animations for everything(idle, attack, block, ect). ive been trying to make it work, but it just wont. This is my CharacterSelector module so you know how i track the character being played.

ocean ibex
#

nicely done but you need to use OOP man module script alone isn't enough

#

do you know how to do OOP in lua?

#

oh and I can see you didn't mention module as a variable maybe the video is cut but also you never return the character array which means the whole module won't work.

and wrong use of module script cause module script does not pass the same data in side it so every time you append new thing to that table the table is then gone forever so that means that character table is always empty

long swallow
#

what i would do is firstly make the animations, upload them to roblox and then store them in a module script under the character

when u spawn in, there is a signal for characterAdded, i use that.

i would then get the humanoid
and by using

Humanoid.Running:Connect(function(speed: number)

end)

if the speed is 0, i stop all other anims and play the idle animation
if for example you have a walk/sprint system, and the walking speed is 12, if the speed value is under 12, you'd play the walk animation

and if its over 12 you eould play your run animation

i apologize for big yap, but it had to be done

#

when u have ur animation IDs you would need to create an 'Animation' instance and would need to load it

ocean ibex
#

the variable "module"

#

was not mention as a local variable in the video

ocean ibex
ocean ibex
#

which in this case the module script will store the value but that instance of an array are not global so it will be deleted after appending

#

or maybe I just got it wrong

long swallow
ocean ibex
#

Fr use OOP for this is the best option in my opinion

azure lance
#

@ocean ibex it fully works as far as switching characters and weapons, no, i have no clue what oop is, and its stored in replecated storage, i call it using Top Bar plus, the bar that most battlegrounds use

#

i also still need the part that adds the moves, but first i need... you know... moves to add

#

and thank you on the well done, i was worried that my way of doing it was unnecesary or jank

odd hound
#

just determine what animation you need to play based on whatever character the player has selected when they attack, oop (classes) make it easier if you know what youre doing but its not necessary

azure lance
#

@odd hound do classes in studio work similer to classes in java? im very familier with java so if there are it should be a breeze