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
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)