Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Change player animation with GUI button?

Hello, i am relatively new to Lua (so far ive been scripting from a bit of c# knowledge made into lua and alot of tutorials) and i am currently making a game where you can morph into diffrent characters from various games. The problem is, some of them are pretty unique so the default animations dont work. I wanted to make it so that when you click the "Select" button on the character selection GUI that it also changes the player animation to my custom animations, but i cannot find anything other than changing default animations. If anyone could give me some "directions" to achieving this, or any articles/sites with something like this, it would be very appreciated. Thank you in advance and have a nice day :)

extra info if needed; i have searched many internet sites and googled various things but i cannot find anything like what i need, only how to change default animations that dont variate based on scripts/GUI buttons

1 answer

✓ Accepted answer

You can change animations inside of the "Animate" script found in the LocalPlayer's character.

The content varies depending on your rig type, (r6 or r15), but you can just look around inside of it depending on your rig type.

You can find a bunch of values named "Run", "Walk," etc.

Inside of each value, there is an Animation instance. Just change the AnimationId property to your animation's id and you're good.

You can fire this from a GuiButton by using

local btn = pathtobtn

btn.MouseButton1Click:Connect(function()
	--code
end)

3 comments

0

Thank you for your help, though i cannot get it to work. I put your code in a script, and put a print in the spot of the "--code" (and did specify the path to the button) but whenever i click the button it doesnt print the text. Im not sure if the script is in the wrong place, since it is currently in Workspace. Thank you for your help still!

0

Yeah. This is a local script. This would go inside of the button.

0

Thannks for ur help! i found another script basically doing what i wanted it to, but still thank you. Have a nice day!

This discussion is preserved as it was. New answers, comments, and votes are closed.