Ad
Still have questions? Join our Discord server and get real time help.
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 8 months 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 192 — 8mo

1 answer

Log in to vote
0
Answered by 8 months ago
Edited 8 months 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 EzireBlueFlame 9 — 8mo
1
Yes of course, my error. It work now I have testing. NiniBlackJackQc 624 — 8mo
Ad

Answer this question