I'm basically implementing a script where it plays an audio object and shuts down the server after a minute if the main object in the game goes missing.
while true do if workspace["Core"] then print("Core Exists") else print("ERROR: CORE MISSING") script.Parent:Play() local H = Instance.new("Hint",game.Workspace) H.Text = "ERROR: Core Model is Missing or Destroyed. The server will be shut down in about 1 minute." wait(60) for i,v in pairs(game.Players:GetPlayers()) do v:Kick("Server was shut down due to the Core being missing or destroyed.") end break end wait(1) end
Well I think the problem here is that you're using a loop when you should be using Events instead.
function onChildRemoved(removedInstance) if removedInstance.Name == "Core" then for i,v in pairs(Players:GetPlayers()) do v:Kick("Server shutdown!") end else print("Phew, core is still here :D") end end workspace.ChildRemoved:Connect(onChildRemoved)
In the code above we have a function that fires every time a child is removed from the workspace. The function checks if the instance that was removed was the Core, and if that's the case we kick everyone. If the core is still there then we will do nothing.