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

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

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)

1 comment

0

Best bet is that you either didn't preload it, or the required joints in the animation aren't apparent.

1 answer

✓ Accepted answer

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!

2 comments

1

also they should check the animation priority or whatever.

0

also they should check the animation priority or whatever.

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