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

Animating Custom Player Rigs?

How do I apply my walking animation to my custom player rigs? I've tried repeatedly for the past 3 days and I couldn't figure it out. It won't run the walking animation. I found something that did help me out but it only plays the animation while pressing 'W'. But a problem with that script, it won't stop running animation (It's a looped walking animation) I want it to stop the animation as soon as you release the key.

        local Service = game:GetService("UserInputService")
local animation = Instance.new("Animation")
local player = game.Players.LocalPlayer
local char = player.Character

Service.InputBegan:connect(function(input, recieved)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.W then

            repeat

            print('Input W')
        animation.AnimationId = "http://www.roblox.com/Asset?ID=485533211" 
        local animTrack = player.Character.Humanoid:LoadAnimation(animation) 
            animTrack:Play()
            wait(1)



        until

            Service.InputEnded:connect(function(input, recieved)
            if input.UserInputType == Enum.UserInputType.Keyboard then
            if input.KeyCode == Enum.KeyCode.W then

            print('Input W stahped')
        local animTrack = player.Character.Humanoid:LoadAnimation(animation) 
            animTrack:Stop()

                    end
                end
            end)
        end
    end
end)

This is the script I'm using for reference ^

2 answers

You can't do this with a Animationvariable. You can only do this using CFrame.

1 comment

0

What do you mean? You're able to animate rigs using ROBLOX's animator. I also said that script I'm using for reference works. The only problem is that when the key is released, the animation won't stop. And the second problem, I can't figure out how to also input 'A', 'S', and 'D'.

Try this out: made the functions separate.

local Service = game:GetService("UserInputService")
local animation = Instance.new("Animation")
local player = game.Players.LocalPlayer
local char = player.Character

Service.InputBegan:connect(function(input, recieved)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.W then
			animation.AnimationId = "http://www.roblox.com/Asset?ID=485533211" 
			local animTrack = player.Character.Humanoid:LoadAnimation(animation) 
			animTrack:Play()
			wait(1)
		end
	end
end)

Service.InputEnded:connect(function(input, recieved)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.W then
			local animTrack = player.Character.Humanoid:LoadAnimation(animation) 
			animTrack:Stop()
		end
	end
end)

2 comments

0

Alright, but now how do I apply it to 'A', 'S', and 'D'?

0

What do you mean?

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