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

Where would I place LoadAnimation() and Play() in this script?

here's the script;

local Punch = script.Parent
 
function onActivation()
    print("Tool activated")
	wait()
	local Humanoid = Punch.Parent:WaitForChild("Humanoid")
	local CloneAnime = game.ReplicatedStorage.Animation.Humanoid:Clone()
end
 
Punch.Activated:connect(onActivation)

I just don't know where to place LoadAnimation() then Play(). Please help.

1 answer

✓ Accepted answer

You've got most of it right, but one thing - there's no need to clone the animation.

Use the LoadAnimation function on 'Humanoid' after line 7 to retrieve the animation's AnimationTrack . Then use the Play function on the AnimationTrack.

local Punch = script.Parent;
local Animation = game.ReplicatedStorage.Animation;

function onActivation()
	print("Tool activated")
	local Humanoid = Punch.Parent:WaitForChild("Humanoid")
	local anim = Humanoid:LoadAnimation(Animation);
	anim:Play();
end

Punch.Activated:connect(onActivation)

4 comments

0

what's about teh animation Id?

0

The AnimationId property should already be set on the Animation in ReplicatedStorage

0

do I inclue the ;s

0

semicolons have no syntactical function in Lua. You can go with or without.

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