You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
A script that loads stages for my project, based off of Tower Of Hell. -
What is the issue? Include screenshots / videos if possible!
The script will not do anything, but also does not give any errors. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
None
Script:
local serverStorage = game:GetService("ServerStorage")
local repStorage = game:GetService("ReplicatedStorage")
local stagesStorage = serverStorage.Stages
local stagesList = stagesStorage:GetChildren()
local loadedStages = Instance.new("Folder")
loadedStages.Parent = workspace
loadedStages.Name = "Currently loaded stages"
local totalTimeValue = repStorage.TotalTime
local lengthValue = repStorage.TowerHeight
local function loadNewStages(length)
for _, player in pairs(game.Players:GetPlayers()) do
player.Character.HumanoidRootPart.CFrame = workspace.WorldSpawn.CFrame
end
loadedStages:ClearAllChildren()
local previouslyLoadedCenter = workspace.Base
for loaded = 0, length, 1 do
local randomNumberChoice = math.random(#stagesList)
local clonedStage = stagesList[randomNumberChoice]:Clone()
clonedStage.Parent = loadedStages
clonedStage.PrimaryPart = clonedStage.StageBase.Center
local refrencePart = Instance.new("Part")
refrencePart.Anchored = true
refrencePart.Transparency = 1
refrencePart.CanCollide = false
refrencePart.Size = clonedStage.PrimaryPart.Size
local yPos = (previouslyLoadedCenter.Size.Y/2)+(clonedStage.PrimaryPart.Size.Y/2)
refrencePart.Position = Vector3.new(previouslyLoadedCenter.Position.X,yPos,previouslyLoadedCenter.Position.Z)
refrencePart.Orientation = previouslyLoadedCenter.Orientation + 180
clonedStage:SetPrimaryPartCFrame(refrencePart)
refrencePart:Destroy()
end
end
totalTimeValue:GetPropertyChangedSignal("Value"):Connect(function()
if totalTimeValue.Value == 0 then
totalTimeValue.Value = 450
loadNewStages(lengthValue.Value)
end
end)
When the game starts, (to start the loading) the TotalTime value switches from 450 (the round time in seconds), to 0.
Edit:
After running the game for some time, one error has appeared:
ServerScriptService.StageLoader:35: invalid argument #2 (Vector3 expected, got number)