hello i need some help with my AFK System! (Read below)
local remote = game.ReplicatedStorage.isAFK
remote.OnServerEvent:Connect(function(plr, isAFK)
if isAFK == "AFK" then
local afkVal = Instance.new("BoolValue")
afkVal.Name = "isAFK"
afkVal.Parent = plr
local BillboardGui = game.ReplicatedStorage.BillboardGui:Clone()
BillboardGui.Parent = plr.Character.Head
else
plr.isAFK:Destroy()
plr.Character.Head.BillboardGui:Destroy()
end
end)
in round system
inRound.Changed:Connect(function()
if inRound.Value == true then
for i, plr in pairs(game.Players:GetChildren()) do
if not plr:FindFirstChild("isAFK") then
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
humanRoot.CFrame = game.Workspace.DropGame.RoundSpawn.CFrame
plr.Team = playingTeam
char:WaitForChild("Humanoid").Died:Connect(function()
wait(2)
plr.leaderstats.Deaths.Value += 1
plr.Team = lobbyTeam
end)
end
end
in button:
local plr = game.Players.LocalPlayer
local button = script.Parent
local remote = game.ReplicatedStorage.isAFK
button.MouseButton1Click:Connect(function()
if not plr:FindFirstChild("isAFk") then
button.Text = "Not AFK"
remote:FireServer("AFK")
else
button.Text = "AFK"
remote:FireServer("not AFK")
end
end)
it just enabeling but it cant be disabled!