local UIS = game:GetService("UserInputService")
local M1Swing1 = script.Parent-- animation
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
print("user pressed E")
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char.Humanoid
local M1Swing1Track = hum:LoadAnimation(M1Swing1)
M1Swing1Track:Play()-- making the track
print("Script Worked")
end
end)
All the prints ran successfully and I have no output error. The issue is that the animation would not load.
local UIS = game:GetService(“UserInputService”)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
local player = game.Players.LocalPlayer
local Animate
local Humanoid = player.Character:FindFirstChild('Humanoid')
local Animation = Instance.new("Animation", player.Character)
Animation.AnimationId = "rbxassetid://" -- your animationid
Animate = Humanoid:LoadAnimation(Animation)
Animate:Play()
end
Mistake, humanoid:LoadAnimation is deprecated. try animator:LoadAnimation instead:
local function playAnimationFromServer(character, animation)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
-- need to use animation object for server access
local animator = humanoid:FindFirstChildOfClass("Animator")
if animator then
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()
return animationTrack
end
end
end