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

How do I run a animation off a player?

So I made a surface gui, then a scrolling frame, then a text button. I put a animation into the button then put in the animation Id. I inserted a script into the button.

local animation = script.Parent.Animation1

script.Parent.MouseButton1Click:Connect(function()
	animation:Play
end

I later figured out what's wrong with it. I'm not actually running it off a player. I have no clue how to do that though. I assume it would be something like, local Player = game.Players.LocalPlayer

But if I do that I have no clue how to run the animation off the player. Any help with this would be amazing. Thanks!

1 answer

you have to load the animation to the humanoid. and make sure the animation id is set

local player = game:GetService("Players).LocalPlayer
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")

if humanoid then
	humanoid:LoadAnimation(animation)
	animation:Play()
end

1 comment

0

I tried this. and it didn't work. local animation = script.Parent.Animation local player = game:GetService("Players").LocalPlayer local character = player.Character local humanoid = character:FindFirstChild("Humanoid") script.Parent.MouseButton1Click:Connect(function() if humanoid then humanoid:LoadAnimation(animation) animation:Play() end end)

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