Animation doesn't play

I have the following script inside a module, and the .sip() function gets called randomly inside a NPC or a Tool.Activated event for players. No animations work, no errors. “drink” does print though. Any ideas?

local module = {}
local Tool = script.Parent

local LoadedSpillAnim = nil
local LoadedDrinkAnim = nil

function module.sip(Setting)
	local Character = Tool.Parent
	local raycastParams = RaycastParams.new()
	raycastParams.IgnoreWater = true
	raycastParams.FilterDescendantsInstances = {Character}
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	local Humanoid = Character.Humanoid
	local Animator = Humanoid.Animator
	local ChosedChance = math.random(1,100)
	local DrinkAnim = Animator:LoadAnimation(Tool.Drink)
	if LoadedDrinkAnim == nil then LoadedDrinkAnim = DrinkAnim end
	local SpillAnim = Animator:LoadAnimation(Tool.Drink)
	if LoadedSpillAnim == nil then LoadedSpillAnim = SpillAnim end
	if Setting == "Player" then
		if ChosedChance > 25 then
			print("drink")
			DrinkAnim:Play() -- tried LoadedDrinkAnim, no luck
		elseif ChosedChance <= 10 then
			LoadedSpillAnim:Play()
			coroutine.wrap(function()
				Character.HumanoidRootPart.Anchored = true
				task.wait(LoadedSpillAnim.Length)
				Character.HumanoidRootPart.Anchored = false
			end)()
			task.wait(2)
			game:GetService("Chat"):Chat(Character.Head,"Oh, silly me...")
			workspace.World.Values.IsBotBroken.Value = true
		end
	elseif Setting == "NPC" then
		LoadedSpillAnim:Play()
		coroutine.wrap(function()
			Character.HumanoidRootPart.Anchored = true
			task.wait(LoadedSpillAnim.Length)
			Character.HumanoidRootPart.Anchored = false
		end)()
		task.wait(2)
		game:GetService("Chat"):Chat(Character,"Oh, silly me...")
		workspace.World.Values.IsBotBroken.Value = true
	end
end

return module

Does it work in studio?

If not, then you have to upload the animation yourself

It does not work in studio and I have uploaded the Animation. I fixed it by apparently updating it, since the uploaded version was empty…?

1 Like