I need help detecting if a server is no longer available and deleting the text-button specified to that place, the folder with the server data already gets deleted once the server is gone but I can’t seem to find a way to send this information to the function and remove the text button.
(PS its my first time using message service/making a server list)
local TweenService = game:GetService("TweenService")
local activeServers = {}
local function refreshServer()
local serverFrames = {}
for i,v in pairs(game.ReplicatedStorage.Servers:GetChildren()) do
if script.Parent.Frame:FindFirstChild(v.Name) and game.ReplicatedStorage.Servers:FindFirstChild(v.Name) then
warn("Already a server")
return
end
warn(v.Name)
local Template = script.Template:Clone()
local id = v.Name
Template.Name = v.Name
Template.Parent = script.Parent.Frame
Template:WaitForChild("PlayerCount").Text = v:WaitForChild("Players").Value.."/"..v:WaitForChild("MaxPlayers").Value
Template:WaitForChild("ServerID").Text = v.Name
table.insert(serverFrames,Template)
Template.MouseEnter:Connect(function()
TweenService:Create(Template.UIStroke, TweenInfo.new(0.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {
Color = Color3.fromRGB(255,255,255);
}):Play()
end)
Template.MouseLeave:Connect(function()
TweenService:Create(Template.UIStroke, TweenInfo.new(0.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {
Color = Color3.fromRGB(0, 0, 0);
}):Play()
end)
Template.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Requests.Teleport:FireServer(id)
end)
end
end
refreshServer()
game.ReplicatedStorage.Servers.ChildAdded:Connect(refreshServer)
game.ReplicatedStorage.Servers.ChildRemoved:Connect(refreshServer)