local remoteevent = game.ReplicatedStorage.ResetServer
local function ResetServer()
game.Lighting:ClearAllChildren()
game.StarterPack:ClearAllChildren()
game.ServerStorage.Baseplate:Clone().Parent = workspace
game.Lighting.FogEnd = 100000000
game.Lighting.Ambient = Color3.fromRGB(0,0,0)
game.Lighting.OutdoorAmbient = Color3.fromRGB(128, 128, 128)
for i,v in pairs(workspace:GetChildren()) do
if v.Name ~= "Terrain" and v:FindFirstChild("Humanoid") then -- here should be does not find first child
v:Destroy()
wait(1)
game.ServerStorage.Baseplate:Clone().Parent = workspace
end
end
end
remoteevent.OnServerEvent:Connect(ResetServer)
COMMUNITY QUESTION
how to make an event if it does not find a first child?
1 answer
Hello, here is how:
local remoteevent = game.ReplicatedStorage.ResetServer
local function ResetServer()
game.Lighting:ClearAllChildren()
game.StarterPack:ClearAllChildren()
game.ServerStorage.Baseplate:Clone().Parent = workspace
game.Lighting.FogEnd = 100000000
game.Lighting.Ambient = Color3.fromRGB(0,0,0)
game.Lighting.OutdoorAmbient = Color3.fromRGB(128, 128, 128)
for i,v in pairs(workspace:GetChildren()) do
local find = v:FindFirstChild("Humanoid")
if v.Name ~= "Terrain" and not find then -- if not that object, than destroy.
v:Destroy()
wait(1)
game.ServerStorage.Baseplate:Clone().Parent = workspace
end
end
end
remoteevent.OnServerEvent:Connect(ResetServer)
Hope it helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.
