local event = game:GetService("ReplicatedStorage"):WaitForChild("AFKRemote")
--local T=game.ReplicatedStorage:WaitForChild("Time")
event.OnServerEvent:Connect(function(player)
if player.AFK.Value == true and #game.Workspace.MainFrame.InRound:GetChildren() == nil then
local val = Instance.new("StringValue")
val.Name = player.Name
val.Parent = game.Workspace.MainFrame.InRound
player.AFK.Value = false
print("Player no longer AFK")
else
while game.Workspace.MainFrame.InRound:FindFirstChild(player.Name) == nil do
wait(1)
print("Player is not in round!")
player.AFK.Value = true
end
game.Workspace.MainFrame.InRound:FindFirstChild(player.Name):Destroy()
player.AFK.Value = true
print("Player currently AFK")
--[[while player.AFK.Value == false do
wait(5)
game.Workspace.MainFrame.InRound:WaitForChild(player.Name):Destroy()
end]]--
end
end)
This is my script in ServerScriptService and It’s called RemoteEventHandler which then the button is clicked it will fire an event which will change the player.AFK.Value to false so that the player is afk and not in the game. So after each game it will add the player to the InRound folder even while the afk is false. Is there anyway for the script to constanly :Destroy() the player when the value is false. As you can see in the comments that is the new part I added. I’m still learning to script and I’ve trying to figure this out for a while now.
So what I am trying to figure out is there a way to destroy the players name from the Inrounds Folder while the Value being false. It only does it once.
This is the current script main script which handles the players:
local function intermission()
repeat wait()
local player=game.Players:GetChildren()
for i=1,#player do
local val=Instance.new("StringValue")
val.Name=player[i].Name
val.Parent=game.Workspace.MainFrame.InRound
end
while #game.Workspace.MainFrame.InRound:GetDescendants()<minPlayers do
M.Value=(minPlayers.." Players are required to play...")
wait(1)
end
for i=10,0,-1 do
T.Value=i
wait(1)
end
local GS=0--GS=Game Starting
M.Value = (minPlayers.." Players are required to play...")
until #game.Workspace.MainFrame.InRound:GetDescendants() >= minPlayers
wait(1)
local GS=0--GS=Game Starting
repeat
M.Value="Game Starting."
wait(0.3)
M.Value="Game Starting.."
wait(0.3)
M.Value="Game Starting..."
wait(0.3)
GS=GS+1
until GS==2
end
This is the settings Script which toggles it:
local player = game.Players.LocalPlayer
local trigger = true -- On {0.25, 0},{0.5, 0} c =34, 255, 0
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("AFKRemote")
script.Parent.MouseButton1Click:Connect(function()
if trigger == true then
print("You are now AFK")
Remote:FireServer()
script.Parent.Parent.Move:TweenPosition(UDim2.new(0.25, 0, 0.5, 0), "Out", "Quart", 0.3)
script.Parent.Parent.Move.ImageColor3 = Color3.fromRGB(34, 255, 0)
trigger = false
else
print("You are not afk")
script.Parent.Parent.Move:TweenPosition(UDim2.new(0.75, 0, 0.5, 0), "Out", "Quart", 0.3)
script.Parent.Parent.Move.ImageColor3 = Color3.fromRGB(255, 78, 81)
trigger = true
end
end)