Currently, I can only do !start once. After I do !ref (which refreshes the map), the !start breaks.
local Players = game:GetService("Players")
local serverstorage = game:GetService("ServerStorage")
local replicatedStorage = game:GetService("ReplicatedStorage")
local AmountOfPlayers = #Players:GetPlayers()
local folder = workspace.Game.Scriptable.Pillars:GetChildren()
local amountValue = #folder
local PlayersService = game:GetService("Players")
local StringToDetect = "!start"
local string2 = "!ref"
Players.PlayerAdded:Connect(function(Player)
AmountOfPlayers = AmountOfPlayers + 1
end)
Players.PlayerRemoving:Connect(function(Player)
AmountOfPlayers = AmountOfPlayers - 1
end)
PlayersService.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message1)
print(AmountOfPlayers)
if string.find(string.lower(Message1), string.lower(string2)) then
workspace.Game.Scriptable.Pillars:Destroy()
local pillarClone = replicatedStorage.Pillars:Clone()
pillarClone.Name = "Pillars"
pillarClone.Parent = workspace.Game.Scriptable
end
end)
Player.Chatted:Connect(function(Message)
print(AmountOfPlayers)
if string.find(string.lower(Message), string.lower(StringToDetect)) then
amountValue = #folder
repeat wait(0.0001)
folder[math.random(#folder)]:Destroy()
until #(workspace.Game.Scriptable.Pillars:GetChildren()) == #Players:GetPlayers()
if #(workspace.Game.Scriptable.Pillars:GetChildren()) == #Players:GetPlayers() then
end
end
end)
end)
local Players = game:GetService("Players")
local serverstorage = game:GetService("ServerStorage")
local replicatedStorage = game:GetService("ReplicatedStorage")
local AmountOfPlayers = #Players:GetPlayers()
local folder = workspace.Game.Scriptable.Pillars:GetChildren()
local amountValue = #folder
local PlayersService = game:GetService("Players")
local StringToDetect = "!start"
local string2 = "!ref"
Players.PlayerAdded:Connect(function(Player)
AmountOfPlayers = AmountOfPlayers + 1
end)
Players.PlayerRemoving:Connect(function(Player)
AmountOfPlayers = AmountOfPlayers - 1
end)
PlayersService.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message1)
print(AmountOfPlayers)
if string.find(string.lower(Message1), string.lower(string2)) then
workspace.Game.Scriptable.Pillars:Destroy()
local pillarClone = replicatedStorage.Pillars:Clone()
pillarClone.Name = "Pillars"
pillarClone.Parent = workspace.Game.Scriptable
end
end)
Player.Chatted:Connect(function(Message)
print(AmountOfPlayers)
if string.find(string.lower(Message), string.lower(StringToDetect)) then
amountValue = #folder
while wait() do
repeat task.wait()
folder[math.random(#folder)]:Destroy()
until #(workspace.Game.Scriptable.Pillars:GetChildren()) == #Players:GetPlayers()
if #(workspace.Game.Scriptable.Pillars:GetChildren()) == #Players:GetPlayers() then
end
end
end
end)
end)
local Players = game:GetService("Players")
local Server = game:GetService("ServerStorage")
local Replicated = game:GetService("ReplicatedStorage")
local Pillar = Replicated:WaitForChild("Pillars")
local GameFolder = workspace:WaitForChild("Game")
local Scriptable = GameFolder:WaitForChild("Scriptable")
local PillarFolder = Scriptable:WaitForChild("Pillars")
local AmountOfPlayers = nil
Players.PlayerAdded:Connect(function(Player)
AmountOfPlayers = #Players:GetPlayers()
Player.Chatted:Connect(function(Message)
print(AmountOfPlayers)
if string.find(string.lower(Message), "!ref") then
PillarFolder:Destroy()
local pillarClone = Pillar:Clone()
pillarClone.Name = "Pillars"
pillarClone.Parent = Scriptable
elseif string.find(string.lower(Message), "!start") then
local Pillars
repeat task.wait()
Pillars = PillarFolder:GetChildren()
Pillars[math.random(#Pillars)]:Destroy()
until #Pillars == #Players:GetPlayers()
if #(PillarFolder:GetChildren()) == #Players:GetPlayers() then
end
end
end)
end)
Players.PlayerRemoving:Connect(function(Player)
AmountOfPlayers = #Players:GetPlayers()
end)
There isn’t a command named “!restart” but the command named “!ref” deletes the Pillars folder which is referenced inside the command named “!start” if this isn’t intended then remove the PillarFolder:Destroy() line.
You’d need to loop over the folder’s children and then destroy those instead of the entire folder. Is the instance named “Pillars” inside of ReplicatedStorage a folder of pillars? If so the code which clones that will need to be changed slightly as well.
local Players = game:GetService("Players")
local Server = game:GetService("ServerStorage")
local Replicated = game:GetService("ReplicatedStorage")
local StoragePillars = Replicated:WaitForChild("Pillars")
local GameFolder = workspace:WaitForChild("Game")
local Scriptable = GameFolder:WaitForChild("Scriptable")
local WorkspacePillars = Scriptable:WaitForChild("Pillars")
local AmountOfPlayers = nil
Players.PlayerAdded:Connect(function(Player)
AmountOfPlayers = #Players:GetPlayers()
Player.Chatted:Connect(function(Message)
print(AmountOfPlayers)
if string.find(string.lower(Message), "!ref") then
for _, Pillar in ipairs(WorkspacePillars:GetChildren()) do
Pillar:Destroy()
end
for _, Pillar in ipairs(StoragePillars:GetChildren()) do
local PillarClone = Pillar:Clone()
PillarClone.Name = "Pillars"
PillarClone.Parent = WorkspacePillars
end
elseif string.find(string.lower(Message), "!start") then
local Pillars
repeat task.wait()
Pillars = WorkspacePillars:GetChildren()
Pillars[math.random(#Pillars)]:Destroy()
until #Pillars == #Players:GetPlayers()
end
end)
end)
Players.PlayerRemoving:Connect(function(Player)
AmountOfPlayers = #Players:GetPlayers()
end)