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

the animations are not playing?

Asked by 3 years ago

i am making a custom character

the script is in starter player scripts

game.Workspace.Camera.CameraType = Enum.CameraType.Attach
local UIS = game:GetService("UserInputService")

local animations_folder = script:WaitForChild("animations")
local player = script.Parent
local humanoid = player.Humanoid

local jump_forward = animations_folder:WaitForChild("jump_forward")
local run = animations_folder:WaitForChild("run")
local left = animations_folder:WaitForChild("left")
local forward = animations_folder:WaitForChild("forward")
local jump = animations_folder:WaitForChild("jump")
local backward = animations_folder:WaitForChild("backward")
local right = animations_folder:WaitForChild("right")

local jump_forward_anim = humanoid.Animator:LoadAnimation(jump_forward)
local run_anim = humanoid.Animator:LoadAnimation(run)
local left_anim = humanoid.Animator:LoadAnimation(left)
local forward_anim = humanoid.Animator:LoadAnimation(forward)
local jump_anim = humanoid.Animator:LoadAnimation(jump)
local backward_anim = humanoid.Animator:LoadAnimation(backward)
local right_anim = humanoid.Animator:LoadAnimation(right)

local positions_folder = script.positions
local head_pos_value = positions_folder.head.Value

function input_started()
    if UIS:IsKeyDown(Enum.KeyCode.Space) then
        jump_anim:Play()
    end
    if UIS:IsKeyDown(Enum.KeyCode.Space) and UIS:IsKeyDown(Enum.KeyCode.W) then
        jump_forward_anim:Play()
    end
    if UIS:IsKeyDown(Enum.KeyCode.A) then
        left_anim:Play()
    end
    if UIS:IsKeyDown(Enum.KeyCode.W) then
        forward_anim:Play()
        humanoid.WalkSpeed = 10
        run_anim:Stop()
    end
    if UIS:IsKeyDown(Enum.KeyCode.LeftShift) and UIS:IsKeyDown(Enum.KeyCode.W) then
        run_anim:Play()
        humanoid.WalkSpeed = 20
    end
    if UIS:IsKeyDown(Enum.KeyCode.S) then
        backward_anim:Play()
    end
    if UIS:IsKeyDown(Enum.KeyCode.D) then
        right_anim:Play()
    end
end

function input_stopped()
    jump_anim:Stop()
    left_anim:Stop()
    forward_anim:Stop()
    run_anim:Stop()
    backward_anim:Stop()
    right_anim:Stop()
end

while true do
    UIS.InputBegan:Connect(input_started)
    UIS.InputEnded:Connect(input_stopped)
    wait(0.1)
end

Answer this question