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

My animation isn't working at all, why isn't it loading?

Asked by
TtuNkK 37
4 years ago

I'm just trying to make a spell based on an anime, but right now I'm just trying to get the animation to work, but it's not. Someone, please help!!

Local Script

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local rArm = {ruArm = char:WaitForChild("RightUpperArm"), rlArm = char:WaitForChild("RightLowerArm"), rHand = char:WaitForChild("RightHand")}
local human = char:WaitForChild("Humanoid")
--Animation
local animInstance = Instance.new("Animation")
animInstance.AnimationId = "rbxassetid://4702042203"
local pistolAnim = human:LoadAnimation(animInstance)

UIS.InputBegan:Connect(function(key, processed)
    if processed then return end
    if key.UserInputType == Enum.UserInputType.Keyboard then

        if key.UserInputType == Enum.KeyCode.E then
            if UIS:IsKeyDown(Enum.KeyCode.E) then
                pistolAnim:Play()

            end
        end
    end
end)
0
Best bet is that you either didn't preload it, or the required joints in the animation aren't apparent. Fifkee 2017 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You don't really need that if statement on line 13, since you're looking for a keyboard input anyway. But your problem is that on line 15, you're comparing UserInputType with a keycode.

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or plr.CharacterAdded:Wait()
local rArm = {ruArm = char:WaitForChild("RightUpperArm"), rlArm = char:WaitForChild("RightLowerArm"), rHand = char:WaitForChild("RightHand")}
local human = char:WaitForChild("Humanoid")
--Animation
local animInstance = Instance.new("Animation")
animInstance.AnimationId = "rbxassetid://4702042203"
local pistolAnim = human:LoadAnimation(animInstance)

UIS.InputBegan:Connect(function(key, processed)
    if processed then return end
        if key.KeyCode== Enum.KeyCode.E then
            if UIS:IsKeyDown(Enum.KeyCode.E) then
                pistolAnim:Play()
            end
        end
end)

Hope this works for you!

1
also they should check the animation priority or whatever. proqrammed 285 — 4y
0
also they should check the animation priority or whatever. proqrammed 285 — 4y
Ad

Answer this question