Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Animating Custom Player Rigs?

Asked by 8 years ago
Edited 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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

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'. DiamondUnity 5 — 8y
Ad
Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
8 years ago

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)

0
Alright, but now how do I apply it to 'A', 'S', and 'D'? DiamondUnity 5 — 8y
0
What do you mean? FiredDusk 1466 — 8y

Answer this question