Hi, i’m trying to make an overhead gui that adds “[AFK]” to their nametag when they tab out of the window. The afk dosent show up, can someone explain whats the problem?
ServerScriptService script:
local AFKStatus = {}
local AFKEvent = game.ReplicatedStorage:FindFirstChild("AFK")
if not AFKEvent then
AFKEvent = Instance.new("RemoteEvent")
AFKEvent.Parent = game.ReplicatedStorage
AFKEvent.Name = "AFK"
end
local updateAFK = function(player,enable)
local GUI = player.Character:WaitForChild("Head"):WaitForChild("NametagGui")
local AFKTagT = GUI:WaitForChild("UpperText")
if enable then
AFKTagT.Text = player.DisplayName.."[AFK]"
else
AFKTagT.Text = player.DisplayName
end
end
AFKEvent.OnServerEvent:Connect(function(player,enable)
AFKStatus[player] = enable
updateAFK(player,enable)
end)
StarterCharacterScripts Local Script:
local ReplicatedStorageEvent = game.Workspace:WaitForChild("AFK")
game:GetService("UserInputService").WindowFocusReleased:Connect(function()
ReplicatedStorageEvent:FireServer(true)
end)
game:GetService("UserInputService").WindowFocused:Connect(function()
ReplicatedStorageEvent:FireServer(false)
end)
Thank u!