-
What I want to achieve:
I need to make a randomly generated obby like ‘Tower Of Hell’ but in a corridor format. -
The issue:
My code simply won’t run. I tried putting the stages in replicated storage but it made no difference, so I moved the stages back to server storage which I think is safer. -
What I have you tried so far:
I have tried putting the stages into replicated storage and server storage, which has made no difference and then I looked on the developer hub and I couldn’t find anything useful on there. So then I decided to create this post after re-writing my code 10+ times.
There are going to also be power ups as well, but in the code I named them mutators.
Code I have tried:
-- Services Variables --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
-- ServerStorage Variables --
local StageFolder = ServerStorage:WaitForChild("Stages")
local Stages = StageFolder:GetChildren()
-- Workspace Variables --
local Tower = game.Workspace:WaitForChild("Road")
local Storage = game.Workspace:WaitForChild("Storage")
local Lobby = Storage:WaitForChild("Lobby")
local End = Storage:WaitForChild("End")
local SpawnsModel = Lobby:WaitForChild("Spawns")
local Spawns = SpawnsModel:GetChildren()
-- Replicated Storage --
local TimerSpeed = ReplicatedStorage:WaitForChild("TimerSpeed")
local Minutes = ReplicatedStorage:WaitForChild("Minutes")
local Seconds = ReplicatedStorage:WaitForChild("Seconds")
local TimerTag = ReplicatedStorage:WaitForChild("TimerTag")
local MultiplierVisible = ReplicatedStorage:WaitForChild("MultiplierVisible")
local Multiplies = ReplicatedStorage:WaitForChild("Multiplies")
local TowerHeight = ReplicatedStorage:WaitForChild("TowerHeight")
local MutatorsFolder = ReplicatedStorage:WaitForChild("Mutators")
-- Main --
local Set1
local Set2
debounce = false
function NewTower()
debounce = true
-- Set 1 --
Set1 = Stages[math.random(1, #Stages)]:Clone()
Set1.Parent = Tower
Set1.PrimaryPart = Set1:FindFirstChild("End")
Set1:SetPrimaryPartCFrame(Set1.End.CFrame)
local Set1Length = Set1.Length.Value
-- Set 2 --
wait()
Set2 = Stages[math.random(1, #Stages)]:Clone()
Set2.Parent = Tower
Set2.PrimaryPart = Set2:FindFirstChild("End")
Set2:SetPrimaryPartCFrame(Set1.End.CFrame)
local Floor2Length = Set2.Length.Value
end
Minutes.Value = 5
Seconds.Value = 0
TimerSpeed.Value = 1
MultiplierVisible.Value = false
Multiplies.Value = 1
debounce = true
NewTower()
while true do
if Minutes and Seconds and TimerSpeed and Tower and Stages then
repeat
if Seconds.Value <= 9 then
TimerTag.Value = tostring(Minutes.Value)..":0"..tostring(Seconds.Value)
else
TimerTag.Value = tostring(Minutes.Value)..":"..tostring(Seconds.Value)
end
if Seconds.Value <= 0 then
Minutes.Value = Minutes.Value - 1
Seconds.Value = 59
else
Seconds.Value = Seconds.Value - 1
end
wait(TimerSpeed.Value)
until Minutes.Value <= 0 and Seconds.Value <= 0
if Minutes.Value <= 0 and Seconds.Value <= 0 then
TimerTag.Value = "0:00"
end
wait(TimerSpeed.Value)
for i, v in pairs(Players:GetChildren()) do
if v.Character:FindFirstChild("Win") then
v.Character.Win:Destroy()
end
if v:FindFirstChild("Backpack") then
v.Backpack:ClearAllChildren()
end
end
Tower:ClearAllChildren()
Minutes.Value = 5
Seconds.Value = 0
TimerSpeed.Value = 1
MultiplierVisible.Value = false
Multiplies.Value = 1
wait()
NewTower()
for i, v in pairs(Players:GetChildren()) do
v.Character.Torso.CFrame = Spawns[math.random(1, #Spawns)].CFrame
end
for i, v in pairs(MutatorsFolder:GetChildren()) do
v.Value = false
end
end
end
I am not asking for the script, I would just like a pointer in the right direction on where I went wrong and how I can fix it!