Hello there,
I have a problem with my animation. I’m trying to make an AI that will chase you if it sees you. It seems to work perfectly but the animation is glitchy. I think the arm is failing to reach the keyframe position i guess… idk but I guess you can help. So yeah
I tried using AdjustWeight()
but looks like it have nothing to do with it. I also tried making another animate script using LocalScript
inside StarterPlayerScript
but yeah, it still giving me the same result.
Here’s the script:
-- ServerScriptService > Killer > Bot(ModuleScript)
function bot:animate()
local anims = self.Anims
local sounds = self.Sounds
local footstepSound = Sounds:WaitForChild("FootStep")
footstepSound:Clone()
footstepSound.Parent = self.Root
for index, sound in pairs(sounds:GetChildren()) do
if sound then
sound:Clone()
if sound.Name == "Theme" then
sound.Parent = self.Root
sound:Play()
else
sound.Parent = self.Model.Head
end
end
end
local idleAnim = self.Animator:LoadAnimation(anims.Idle)
local walkAnim = self.Animator:LoadAnimation(anims.Walk)
self.Humanoid.Running:Connect(function(speed)
if speed > 0 then
if idleAnim.IsPlaying and not walkAnim.IsPlaying then
idleAnim:Stop()
walkAnim:Play()
end
else
if walkAnim.IsPlaying and not idleAnim.IsPlaying then
walkAnim:Stop()
idleAnim:Play()
end
end
end)
walkAnim:GetMarkerReachedSignal("FootStep"):Connect(function(maxDistance)
if maxDistance then
footstepSound.RollOffMaxDistance = maxDistance
end
footstepSound:Play()
end)
idleAnim:Play()
end
-- StarterPlayer > StarterPlayerScripts
local function animate(bot)
local anims = anims
local idleAnim = bot.Humanoid.Animator:LoadAnimation(anims.Idle)
local walkAnim = bot.Humanoid.Animator:LoadAnimation(anims.Walk)
bot.Humanoid.Running:Connect(function(speed)
if speed > 0 then
if idleAnim.IsPlaying and not walkAnim.IsPlaying then
idleAnim:Stop()
walkAnim:Play()
end
else
if walkAnim.IsPlaying and not idleAnim.IsPlaying then
walkAnim:Stop()
idleAnim:Play()
end
end
end)
end
Please help :]