This is my first time scripting and I would like to know how I could make an idle animation.
I did some research, and I believe you can use GetPropertyChangedSignal
on the character, which can detect if a specified property of the character has changed, i.e velocity.
I saw someone else say this before but you could detect if the character's velocity is less than a number, and if it is, play the animation.
player.Character.Torso:GetPropertyChangedSignal('Velocity'):Connect(function() if player.Character.Torso.Velocity < 5 then -- play animation end end)
Saw this off a devforum. (I hope I'm still allowed to post it?)
Edit the Animate script. You can do that by starting up a play solo game in studio, then going to your character model and opening up the localscript Animate. Copy and paste that script into StarterCharacterScripts
.
Inside the script, there is a table animNames
. Inside the table, the first element is an element with the key idle
. The value is a table of tables. Each table is a table that consists of the properties id
, which has the value of the asset id for the animation, and then another property weight
which you can read more about here.
All you have to do is add a table to the list consisting of your roblox asset id and weight and you will automatically perform the animation randomly when your player is idle.
local animNames = { idle = { { id = "http://www.roblox.com/asset/?id=507766666", weight = 1 }, { id = "http://www.roblox.com/asset/?id=507766951", weight = 1 }, { id = "http://www.roblox.com/asset/?id=507766388", weight = 9 }, { id = "YOUR ASSET ID", weight = yourWeight } }, walk = { -- rest of script
Hope this helps! :)