“Before anyone says to research the site about my problem before posting, i literally did that and their issues are not like mine.”
I’m currently working on a punch combo but whenever i try to play a punch animation, it shows the error "LoadAnimation Requires Animation Object.
This is my coding:
local function Punch_Combo(Character)
local Combo = Character:GetAttribute("Combo")
if Combo >= MAX_PUNCHCOMBO then
Character:GetAttribute("Combo", 1)
else
Character:GetAttribute("Combo", Combo + 1)
end
end
local function GetPunch_ANIMATION(Character)
local Combo = Character:GetAttribute("Combo")
local Punch_Animations = RS_Storage:WaitForChild("Animations"):WaitForChild("Combat"):WaitForChild("Punches"):GetChildren()
local Current_PunchAnimation = Punch_Animations[Combo]
return Current_PunchAnimation
end
local function Stop_ANIMATIONS(Animation_Object)
for i, v in pairs(Animation_Object:GetPlayingAnimationTracks()) do
v:Stop()
end
end
--- Remote Events ---
Remote_Events.Punch_Event.OnServerEvent:Connect(function(Player)
local Player_Character = Player.Character or Player.CharacterAdded:Wait()
local Character_Humanoid = Player_Character:WaitForChild("Humanoid")
local CH_Animator = Player_Character:WaitForChild("Humanoid"):WaitForChild("Animator")
local CH_RootPart = Player_Character:WaitForChild("HumanoidRootPart")
local Attacking = Player_Character:GetAttribute("Attacking")
local Punching = Player_Character:GetAttribute("Punching")
if Attacking or Punching then
return
end
Player_Character:SetAttribute("Attacking", true)
Player_Character:SetAttribute("Punching", true)
Punch_Combo(Player_Character)
Stop_ANIMATIONS(CH_Animator)
GetPunch_ANIMATION(Player_Character)
local PlayPunch_Animation = CH_Animator:LoadAnimation(GetPunch_ANIMATION(Player_Character))
PlayPunch_Animation.KeyframeReached:Connect(function(KF)
if KF == "Hit" then
Player_Character:SetAttribute("Attacking", false)
if Player_Character:GetAttribute("Combo") == MAX_PUNCHCOMBO then
task.wait(1)
end
Player_Character:SetAttribute("Punching", false)
end
end)
PlayPunch_Animation:Play()
end)
The script error when ever i try to play the "PlayPunch_Animation"
variable
I would appreciate it if anyone could help me fix this issue. i’ve been trying to find a solution for an hour on this issue but no luck.