I tried to make the afk system, but when I clicked the afk button, the game started. Can you take a look at a script?
how can i solve
isAFK script:
local remote = game.ReplicatedStorage.isAFK
remote.OnServerEvent:Connect(function(player, isAFK)
if isAFK == "AFK" then
local afkVal = Instance.new("BoolValue")
afkVal.Name = "isAFK"
afkVal.Parent = player
else
player.isAFK:Destroy()
end
end)
Main script( what should I do?):
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
table.remove(AvailableSpawnPoints,1)
-- Give them a gear
local equipped = game.ServerStorage.PlayerData[player.Name].Equipped
if equipped.Value ~= "" then
local weapon = game.ServerStorage.Items[equipped.Value]:Clone()
weapon.Parent = player.Backpack
else
local ClassicSword = ServerStorage.ClassicSword:Clone()
ClassicSword.Parent = player.Backpack
end
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
else
-- There is no character
if not player then
table.remove(plrs,i)
end
end
end
if character:FindFirstChild("isAFK") then
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
table.remove(AvailableSpawnPoints,1)
-- Give them a gear
local equipped = game.ServerStorage.PlayerData[player.Name].Equipped
if equipped.Value ~= "" then
local weapon = game.ServerStorage.Items[equipped.Value]:Clone()
weapon.Parent = player.Backpack
else
local ClassicSword = ServerStorage.ClassicSword:Clone()
ClassicSword.Parent = player.Backpack
end
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
else
-- There is no character
if not player then
table.remove(plrs,i)
end
end
end
Video: