After you kill the animal NPC I have, a proximity prompt will be available that says, “Harvest” you can hold E and it SHOULD be playing a harvesting animation, but it wont for some reason. Also everything else is running, I am pretty sure its “Playing” the animiation because everything else after the Anim:Play() happens, everything else runs fine.
(There are no errors in the output and I’m very lost)
local ProximityPromptService = game:GetService("ProximityPromptService")
local Players = game:GetService("Players")
local proximityPrompt = workspace.NPCS.Squirrel["Right Leg"].ProximityPrompt
local Animation = script.Animation
function getHumanoid(plr)
local char = plr.Character
if not char then return nil end
return char:FindFirstChildWhichIsA("Humanoid")
end
proximityPrompt.Triggered:Connect(function(player)
local controls = require(player.PlayerScripts.PlayerModule):GetControls()
local humanoid = getHumanoid(player)
if not humanoid then return end
local Anim = humanoid:LoadAnimation(Animation)
humanoid:UnequipTools()
proximityPrompt.Enabled = false
controls:Disable()
Anim:Play()
task.wait(5)
game.Lighting.Tools["Squirell Meat"]:Clone().Parent = player.Backpack
proximityPrompt.Parent.Parent:Destroy()
controls:Enable()
Anim:Stop()
end)
local proximityPrompt = workspace.NPCS.Squirrel["Right Leg"].ProximityPrompt
local Animation = script.Animation
function getHumanoid(plr)
local char = plr.Character
if not char then return nil end
return char:FindFirstChildWhichIsA("Humanoid")
end
proximityPrompt.Triggered:Connect(function(player)
local controls = require(player.PlayerScripts.PlayerModule):GetControls()
local humanoid = getHumanoid(player)
if not humanoid then return end
local Anim = humanoid:LoadAnimation(Animation)
while Anim.Length <= 0 do print("loading animation!") task.wait() end
humanoid:UnequipTools()
proximityPrompt.Enabled = false
controls:Disable()
Anim:Play()
task.wait(5)
game.Lighting.Tools["Squirell Meat"]:Clone().Parent = player.Backpack
proximityPrompt.Parent.Parent:Destroy()
controls:Enable()
Anim:Stop()
end)
If it consistently prints that, then they’re chance ur animation isn’t loading correctly, make sure you own the animation and if its a group game then make sure the group owns the animation
Probably not relevant, but you could load it onto animator like you are meant to do (humanoid is deprecated for loading anims)
get rid of your findHumanoid function and add this instead
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local Anim = animator:LoadAnimation(Animation)
And I’m not so sure you need to wait until the length is >0 but try waiting 0.5 sec to debug
local proximityPrompt = workspace.NPCS.Squirrel["Right Leg"].ProximityPrompt
local Animation = script.Animation
function getHumanoid(plr)
local char = plr.Character
if not char then return nil end
return char:FindFirstChildWhichIsA("Humanoid")
end
proximityPrompt.Triggered:Connect(function(player)
local controls = require(player.PlayerScripts.PlayerModule):GetControls()
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local Anim = animator:LoadAnimation(Animation)
if not humanoid then return end
while Anim.Length <= 0 do print("loading animation!") task.wait() end
humanoid:UnequipTools()
proximityPrompt.Enabled = false
controls:Disable()
wait()
Anim:Play()
task.wait(5)
game.Lighting.Tools["Squirell Meat"]:Clone().Parent = player.Backpack
controls:Enable()
Anim:Stop()
proximityPrompt.Parent.Parent:Destroy()
end)