Stop is not a valid member of Animator?

If stop isn’t a valid member how do I make it stop?


local GH 										= require(game.ReplicatedStorage.Modules.GameHandler)
local RepStorage 								= game:GetService("ReplicatedStorage")

game.ReplicatedStorage.Remotes.Gameplay.OnServerEvent:Connect(function(player, Action, Object, Object2)
	elseif Action == "AFK" then
		if player.Character then
			if GH:CheckRig(player.Character) == true then
				if Object == true then
					player.Character.Head:WaitForChild("Overhead", 10)
					player.Character.Head.Overhead.DisplayName.Text = player.DisplayName..[[ <font color="rgb(239, 184, 56)">- AFK -</font>]]
					local AFKAnimation = player.Character:FindFirstChild("Humanoid").Animator:LoadAnimation(Anim)
					AFKAnimation:Play()
				elseif Object == false then
					player.Character.Head:WaitForChild("Overhead", 10)
					player.Character.Head.Overhead.DisplayName.Text = player.DisplayName
					local AFKAnimation = player.Character:FindFirstChild("Humanoid").Animator
					AFKAnimation:Stop()
				end
			end
		end

Are you trying to stop the AnimationTrack?

It seems here that you are trying to stop the Animator not the AnimationTrack.

I believe your code is incomplete, so I’ll try my best.

It looks like you are trying to stop an animation instance. Try creating a table with all animations in it.

local GH 										= require(game.ReplicatedStorage.Modules.GameHandler)
local RepStorage 								= game:GetService("ReplicatedStorage")

local AFKAnimations = {}

game.ReplicatedStorage.Remotes.Gameplay.OnServerEvent:Connect(function(player, Action, Object, Object2)
	if Action == "AFK" then
		if player.Character then
			if GH:CheckRig(player.Character) == true then
				if Object == true then
					player.Character.Head:WaitForChild("Overhead", 10)
					player.Character.Head.Overhead.DisplayName.Text = player.DisplayName..[[ <font color="rgb(239, 184, 56)">- AFK -</font>]]
					AFKAnimations[player.UserId] = player.Character:FindFirstChild("Humanoid").Animator:LoadAnimation(Anim)
					AFKAnimations[player.UserId]:Play()
				elseif Object == false then
					player.Character.Head:WaitForChild("Overhead", 10)
					player.Character.Head.Overhead.DisplayName.Text = player.DisplayName
					AFKAnimations[player.UserId]:Stop()
				end
			end
		end
	end
end)
1 Like

Thank you very much for teaching me the correct way to stop it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.