My script should work but ends are RUINING MY SCRIPT!
Please help, thank you.
hello. i made a script for spawning maps but the script isnt working. there are no errors so i tryed playing around with the ends and its hurting my brain. this is an hour in and i still cannot figure the issue out. (like i said im probably ending the wrong things at the wrong time etc)
script:
local buttons = game.ServerStorage.Folder:WaitForChild("Buttons")
buttons.Changed:Connect(function()
local RandomAM = game.ServerStorage:WaitForChild("Folder"):WaitForChild("RandomLevel")
print("...Hn/text/start/Map_Script by SakDevRblx. Using Script in any game other than H>Hostility<H is not premitted or given premission H> you can contact @Laggy Cat#4063 DiscH>ord {complete sequence[message.start]}")
--------------------------------------------------------------------------------------------------------------------------------------------
-------------------- -MAIN SCRIPT- --------------------
--------------------------------------------------------------------------------------------------------------------------------------------
local buttons = game.ServerStorage.Folder:WaitForChild("Buttons")
buttons.Changed:Connect(function()
if buttons.Value <= 0 then print("Please do something")
--------------------
-- --
-- SETTINGS --
-- --
--Amount Of Floors--
--------------------
RandomAM.Value = 3
--------------------
--Floors--
--------------------
local Hospital = game.ServerStorage.MapHospital:Clone()
--------------------
local Facility = game.ServerStorage.MapOldFacility:Clone()
--------------------
local Wood = game.ServerStorage.WoodHallsMap:Clone()
--------------------
--Essential Configs--
--------------------
local GenA = game.ServerStorage:WaitForChild("Folder"):WaitForChild("GenA")
--------------------
local FloorLV = game.ServerStorage:WaitForChild("Folder"):WaitForChild("FloorLv")
--------------------
local FloorType = game.ServerStorage:WaitForChild("Folder"):WaitForChild("FloorType")
--------------------
local time = 40
--------------------
--Text Changers--
--------------------
local ChatText = game.StarterGui.Playergui.gens.Generators
--------------------
local Chat = game.StarterGui.Playergui.gens
--------------------
while wait(1) do
if time == 0 then
--------------------------------------------------------------------------------------------------------------------------------------------
-------------------- -Wood Halls- --------------------
--------------------------------------------------------------------------------------------------------------------------------------------
if RandomAM.Value == 1 then FloorType = 1
--------------------
--Value of this floor--
--------------------
--------------------------------------------------------------------------------------------------------------------------------------------
if FloorType == 1 then game.Workspace.WoodHallsMap.Parent = nil for _, scr in pairs(game.Workspace.SpawnedGeneratorFor:GetDescendants()) do scr.Parent = nil
Wood.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
elseif FloorType == 2 then game.Workspace.MapHospital.Parent = nil for _, scr in pairs(game.Workspace.SpawnedGeneratorFor:GetDescendants()) do scr.Parent = nil
Wood.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
elseif FloorType == 3 then game.Workspace.MapOldFacility.Parent = nil for _, scr in pairs(game.Workspace.SpawnedGeneratorFor:GetDescendants()) do scr.Parent = nil
Wood.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
else
Wood.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
-------------------- -Hospital- --------------------
--------------------------------------------------------------------------------------------------------------------------------------------
elseif RandomAM.Value == 2 then FloorType = 2
--------------------
--Value of this floor--
--------------------
--------------------------------------------------------------------------------------------------------------------------------------------
if FloorType == 1 then game.Workspace.WoodHallsMap.Parent = nil for _, scr in pairs(game.Workspace.SpawnedGeneratorFor:GetDescendants()) do scr.Parent = nil
Hospital.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
elseif FloorType == 2 then game.Workspace.MapHospital.Parent = nil for _, scr in pairs(game.Workspace.SpawnedGeneratorFor:GetDescendants()) do scr.Parent = nil
Hospital.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
elseif FloorType == 3 then game.Workspace.MapOldFacility.Parent = nil for _, scr in pairs(game.Workspace.SpawnedGeneratorFor:GetDescendants()) do scr.Parent = nil
Hospital.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
else
Hospital.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
-------------------- -Facility- --------------------
--------------------------------------------------------------------------------------------------------------------------------------------
elseif RandomAM.Value == 3 then FloorType = 3
--------------------
--Value of this floor--
--------------------
--------------------------------------------------------------------------------------------------------------------------------------------
if FloorType == 1 then game.Workspace.WoodHallsMap.Parent = nil for _, scr in pairs(game.Workspace.SpawnedGeneratorFor:GetDescendants()) do scr.Parent = nil
Facility.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
elseif FloorType == 2 then game.Workspace.MapHospital.Parent = nil for _, scr in pairs(game.Workspace.SpawnedGeneratorFor:GetDescendants()) do scr.Parent = nil
Facility.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
elseif FloorType == 3 then game.Workspace.MapOldFacility.Parent = nil for _, scr in pairs(game.Workspace.SpawnedGeneratorFor:GetDescendants()) do scr.Parent = nil
Facility.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
--------------------------------------------------------------------------------------------------------------------------------------------
else
Facility.Parent = game.Workspace
GenA.Value = GenA.Value + 2
buttons.Value = GenA.Value
end
end
--------------------------------------------------------------------------------------------------------------------------------------------
-------------------- -TIMER- --------------------
--------------------------------------------------------------------------------------------------------------------------------------------
else
local ChatText = game.StarterGui.Playergui.gens.Generators
ChatText.Text = "Elevator Leaving in "..tostring(time)
print(time)
time = time - 1
end
end
end
end)
end)
SIDE NOTE: when the button value goes to 0 it does nothing