Ad
Log in to vote
0

im trying to make a punch but my script dosent load my animation how can i fix it?

Asked by
eze123456 -17
12 days ago

this script isnt working

local player = game.Players.LocalPlayer
local user = game:GetService("UserInputService")
local mouse = player:GetMouse()
local Animation = Instance.new("Animation")
local Humanoid = player:FindFirstChild("Humanoid")
Animation.AnimationId = "http://www.roblox.com/asset/?id=2625660591"
local animationController = Instance.new("AnimationController")
local animationTrack = animationController:LoadAnimation(Animation)
animationTrack:Play()
local function onKeyDown ( key )`~~~~~~~~~~~~~~~~~

` print ("punch")

mouse.KeyDown:Connect(onKeyDown) end

~~~~~~~~~~~~~~~~~

0
Try finding character too in line 5. Also are there any errors other than "my animation wont load"? HeyItzDanniee 149 — 12d

1 answer

Log in to vote
0
Answered by 12 days ago
Edited 12 days ago

mouse.KeyDown is deprecated use UserInputService

--< Services
local PlayerService = game:GetService('Players')
local UserInputService = game:GetService('UserInputService')

--< Variables
local Player = PlayerService.LocalPlayer
repeat wait() until Player.Character -- wait the character spawn
local Character = Player.Character

local KeyCode = Enum.KeyCode.Q -- The key of the player press to execute animation

-- Create instance
local Animation = Instance.new("Animation", Character)
Animation.AnimationId = "rbxassetid://2625660591"

--< Events
UserInputService.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == KeyCode then
        local AnimationTrack = Character.Humanoid:LoadAnimation(Animation)
        AnimationTrack:Play()
    end
end)
0
I tried it and it didnt work eze123456 -17 — 12d
1
Yes of course, my error. It work now I have testing. NiniBlackJackQc 480 — 12d
Ad

Answer this question