Hello,
I have had very bad experience with animation tracks in my history and this trouble is no different from other struggles. The animation will not play at all even though it is set to Action. Any help will be hugely appreciated
Player Script
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local clickTimes = 0
local DELAY_TIME = 0.5
local db = false
UIS.InputBegan:Connect(function(i,gpe)
if i.UserInputType == Enum.UserInputType.MouseButton1 and not db then
print("Mouse click has begun.")
db = true
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animFolder = workspace:WaitForChild("M1 combo")
clickTimes = math.clamp(clickTimes+1,1,4)
print(clickTimes)
local anim = animFolder["Click " .. clickTimes]
local track = animator:LoadAnimation(anim)
track.Priority = Enum.AnimationPriority.Action
track:Play()
print(clickTimes)
if clickTimes == 4 then
clickTimes = 0
end
task.wait(0.5)
db = false
end
end)
NPC Script
local animFolder = workspace:WaitForChild("M1 combo")
local isPlayingAnim = false
local animTime = 2
local loopTime = 0
--[[
all the print statements work.. but the animations wont play?
]]
while task.wait(animTime) do
print("Works here ?")
if not isPlayingAnim then
print("Works here ? at not isPlayingAnim")
isPlayingAnim = true
local animator = workspace.Dummy:WaitForChild("Humanoid"):WaitForChild("Animator")
loopTime = math.clamp(loopTime+1,1,#animFolder:GetChildren())
local anim = animFolder["Click " .. loopTime]
local track = animator:LoadAnimation(anim)
track.Priority = Enum.AnimationPriority.Action
track:Play()
if track.IsPlaying then
print("Is Playing Track of Name: " .. track.Name)
end
print(track.Name)
if loopTime == #animFolder:GetChildren() then
loopTime = 0
print("Works: " .. tostring(loopTime))
end
task.wait(animTime)
print("works.." .. tostring(animTime)) -- 2, also works
isPlayingAnim = false
print("Set isPlayingAnim to " .. tostring(isPlayingAnim))
end
end