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

How do I make animation commands system?

Asked by 3 years ago
Edited 3 years ago

I'm making an animation commands system(like Press Left CTRL + E to play animation1) But my script is not working Game and animations are my own

Script in StarterCharacterScripts:

local SaluteKeybind = Enum.KeyCode.Q --Salute
local AtEaseKeybind = Enum.KeyCode.Z --At Ease
local AttentionKeybind = Enum.KeyCode.E --Attention
local DressrightKeybind = Enum.KeyCode.V --Dress Right

--Get Services
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")

--Variables
local Player = Players.LocalPlayer
local Character = Player.Character
if not Character or not Character.Parent then
    Character = Player.CharacterAdded:Wait()
end

local Humanoid = Character:WaitForChild("Humanoid")

local SaluteAnimation = Instance.new("Animation")
local AtEaseAnimation = Instance.new("Animation")
local AttentionAnimation = Instance.new("Animation")
local DressrightAnimation = Instance.new("Animation")

SaluteAnimation.AnimationId = "rbxassetid://7180423166"
AtEaseAnimation.AnimationId = "rbxassetid://7169904177"
AttentionAnimation.AnimationId = "rbxassetid://7169902902"
DressrightAnimation.AnimationId = "rbxassetid://7170007540"

local SaluteAnimationTrack = Humanoid:LoadAnimation(SaluteAnimation)
local AtEaseAnimationTrack = Humanoid:LoadAnimation(AtEaseAnimation)
local AttentionAnimationTrack = Humanoid:LoadAnimation(AttentionAnimation)
local DressrightAnimationTrack = Humanoid:LoadAnimation(DressrightAnimation)

SaluteAnimationTrack.Priority = Enum.AnimationPriority.Action
AtEaseAnimationTrack.Priority = Enum.AnimationPriority.Action
AttentionAnimationTrack.Priority = Enum.AnimationPriority.Action
DressrightAnimationTrack.Priority = Enum.AnimationPriority.Action

SaluteAnimationTrack.Looped = true
AtEaseAnimationTrack.Looped = true
AttentionAnimationTrack.Looped = true
DressrightAnimationTrack.Looped = true
--Functions
UIS.InputBegan:Connect(function(Input, GameProcessed)
    --Variables
    local SalutePressed = Input.KeyCode == SaluteKeybind and UIS:IsKeyDown(Enum.KeyCode.LeftControl)
    local AtEasePressed = Input.KeyCode == AtEaseKeybind and UIS:IsKeyDown(Enum.KeyCode.LeftControl)
    local AttentionPressed = Input.KeyCode == AttentionKeybind and UIS:IsKeyDown(Enum.KeyCode.LeftControl)
    local DressrightPressed = Input.KeyCode == AttentionKeybind and UIS:IsKeyDown(Enum.KeyCode.LeftControl)

    --Salute
    if (SalutePressed) then
        SaluteAnimationTrack:Play()
        print("Salute")

    --At Ease
    elseif (AtEasePressed) then
        AtEaseAnimationTrack:Play()
        print("At Ease")

    --Attention
    elseif (AttentionPressed) then
        AttentionAnimationTrack:Play()
        print("Attention")

    --Dress Right
    elseif (DressrightPressed) then
        DressrightAnimationTrack:Play()
        print("Dress Right")

    --Reset Animations
    elseif (Input.KeyCode == Enum.KeyCode.LeftControl) then
        SaluteAnimationTrack:Stop()
        AtEaseAnimationTrack:Stop()
        AttentionAnimationTrack:Stop()
        DressrightAnimationTrack:Stop()
        print("Reset Animation")
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Hello, Same i need to do this but idk why he do not want to work there are one work:

Ad

Answer this question