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)
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!