Vothern
(Vothern)
October 23, 2021, 4:49pm
1
Hi, when loading into the game when there’s an existing server, so there are 3 stages and the height bar displays the stages in the wrong order, is there a way I could fix this?
Height Bar Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Height = script.Parent:WaitForChild("Frame")
local Timer = script.Parent.Parent.Timer:WaitForChild("Timer")
local CandyDisplay = script.Parent.Parent:WaitForChild("Display"):WaitForChild("CandyDisplay")
Height.Visible = true
Timer.Visible = true
CandyDisplay.Visible = true
local Tower = game.Workspace:WaitForChild("Tower")
function CreateSectionFrames(TowerHeight)
wait(1)
for _, Child in pairs(script.Parent.Frame:GetChildren()) do
if Child:IsA("Frame") then
Child:Destroy()
end
end
local ReversedSections = {}
for _ , Section in pairs(Tower:GetChildren()) do
table.insert(ReversedSections, 1, Section)
end
for _, Section in pairs(ReversedSections) do
local Frame = Instance.new("Frame")
Frame.Size = UDim2.new(1, 0, Section.Height.Value/TowerHeight, 0)
Frame.Name = Section.Name
Frame.BorderSizePixel = 0
Frame.BackgroundColor3 = Section.PrimaryPart.Color
Frame.Parent = script.Parent.Frame
end
end
CreateSectionFrames(tonumber(ReplicatedStorage.Values.TowerHeight.Value))
ReplicatedStorage.Events.HeightEvent.OnClientEvent:Connect(function(TowerHeight)
CreateSectionFrames(tonumber(TowerHeight))
end)
Script that clones the stages:
local Floor1
local Floor2
local Floor3
Debounce = false
function NewTower()
Debounce = true
Floor1 = Stages[math.random(1, #Stages)]:Clone()
Floor1.Parent = Tower
Floor1.PrimaryPart = Floor1:FindFirstChild("Center")
Floor1:SetPrimaryPartCFrame(Floor1.Center.CFrame)
local Floor1Height = Floor1.Height.Value
wait()
Floor2 = Stages[math.random(1, #Stages)]:Clone()
Floor2.Parent = Tower
Floor2.PrimaryPart = Floor2:FindFirstChild("Center")
Floor2:SetPrimaryPartCFrame(Floor1.Center.CFrame + Vector3.new(0, Floor1Height, 0))
Floor2:SetPrimaryPartCFrame(Floor2.Center.CFrame * CFrame.Angles(0, math.rad(180), 0))
local Floor2Height = Floor2.Height.Value
wait()
Floor3 = Stages[math.random(1, #Stages)]:Clone()
Floor3.Parent = Tower
Floor3.PrimaryPart = Floor3:FindFirstChild("Center")
Floor3:SetPrimaryPartCFrame(Floor2.Center.CFrame + Vector3.new(0, Floor2Height, 0))
Floor3:SetPrimaryPartCFrame(Floor3.Center.CFrame * CFrame.Angles(0, math.rad(180), 0))
local Floor3Height = Floor3.Height.Value
wait()
End.PrimaryPart = End:WaitForChild("Center")
End:SetPrimaryPartCFrame(Floor3.Center.CFrame + Vector3.new(0, Floor3Height), 0)
End:SetPrimaryPartCFrame(End.Center.CFrame * CFrame.Angles(0, math.rad(180), 0))
Debounce = false
TowerHeight.Value = Floor1Height + Floor2Height + Floor3Height + 30 * 2
ReplicatedStorage.Events.HeightEvent:FireAllClients(TowerHeight.Value)
end
RandomMusic = Music:GetChildren()[math.random(1, #Music:GetChildren())]
RandomMusic:Play()
Minutes.Value = 3
Seconds.Value = 0
TimerSpeed.Value = 1
MultiplierVisible.Value = false
Multiplies.Value = 1
Debounce = true
NewTower()
Any help is appreciated.
Macossaro
(Threthor)
October 23, 2021, 5:07pm
2
Does your UI have an UIListLayout?
If so, it has a SortOrder property. By default, it sorts the frames located in its parent by LayoutOrder, so you must set that in the order you want.
I hope that helps!
Vothern
(Vothern)
October 23, 2021, 5:10pm
3
It has that, but the issue is if someone else were to join the server it would display in the wrong order for the person that joined.
1 Like
Macossaro
(Threthor)
October 23, 2021, 5:13pm
4
Is the character location bar outside the tower display UI?
Vothern
(Vothern)
October 23, 2021, 5:16pm
5
Here’s an image of how it’s the guis are ordered.
The one that isn’t in a frame is the script that is shown in the topic.
local Floor1
local Floor2
local Floor3
Debounce = false
function NewTower()
Debounce = true
Floor1 = Stages[math.random(1, #Stages)]:Clone()
Floor1.Parent = Tower
Floor1.PrimaryPart = Floor1:FindFirstChild("Center")
Floor1:SetPrimaryPartCFrame(Floor1.Center.CFrame)
local Floor1Height = Floor1.Height.Value
wait()
Floor2 = Stages[math.random(1, #Stages)]:Clone()
Floor2.Parent = Tower
Floor2.PrimaryPart = Floor2:FindFirstChild("Center")
Floor2:SetPrimaryPartCFrame(Floor1.Center.CFrame + Vector3.new(0, Floor1Height, 0))
Floor2:SetPrimaryPartCFrame(Floor2.Center.CFrame * CFrame.Angles(0, math.rad(180), 0))
local Floor2Height = Floor2.Height.Value
wait()
Floor3 = Stages[math.random(1, #Stages)]:Clone()
Floor3.Parent = Tower
Floor3.PrimaryPart = Floor3:FindFirstChild("Center")
Floor3:SetPrimaryPartCFrame(Floor2.Center.CFrame + Vector3.new(0, Floor2Height, 0))
Floor3:SetPrimaryPartCFrame(Floor3.Center.CFrame * CFrame.Angles(0, math.rad(180), 0))
local Floor3Height = Floor3.Height.Value
wait()
End.PrimaryPart = End:WaitForChild("Center")
End:SetPrimaryPartCFrame(Floor3.Center.CFrame + Vector3.new(0, Floor3Height), 0)
End:SetPrimaryPartCFrame(End.Center.CFrame * CFrame.Angles(0, math.rad(180), 0))
Debounce = false
TowerHeight.Value = Floor1Height + Floor2Height + Floor3Height + 30 * 2
ReplicatedStorage.Events.HeightEvent:FireAllClients(TowerHeight.Value)
end
RandomMusic = Music:GetChildren()[math.random(1, #Music:GetChildren())]
RandomMusic:Play()
Minutes.Value = 3
Seconds.Value = 0
TimerSpeed.Value = 1
MultiplierVisible.Value = false
Multiplies.Value = 1
Debounce = true
NewTower()
Just fixing the formatting of the 2nd script.
1 Like
Vothern
(Vothern)
October 23, 2021, 5:19pm
7
Oh I didn’t know everything was doublespaced in the topic but thanks.
Macossaro
(Threthor)
October 23, 2021, 5:30pm
8
UIListLayout.VerticalAlignment should be set to Bottom
-- in the tower generation script
function NewTower()
Debounce = true
Floor1 = Stages[math.random(1, #Stages)]:Clone()
Floor1.Parent = Tower
Floor1.PrimaryPart = Floor1:FindFirstChild("Center")
Floor1:SetPrimaryPartCFrame(Floor1.Center.CFrame)
local Floor1OrderNumber = Instance.new("NumberValue",Floor1)
Floor1OrderNumber.Name = "Order"
Floor1OrderNumber.Value = 1
local Floor1Height = Floor1.Height.Value
wait()
Floor2 = Stages[math.random(1, #Stages)]:Clone()
Floor2.Parent = Tower
Floor2.PrimaryPart = Floor2:FindFirstChild("Center")
Floor2:SetPrimaryPartCFrame(Floor1.Center.CFrame + Vector3.new(0, Floor1Height, 0))
Floor2:SetPrimaryPartCFrame(Floor2.Center.CFrame * CFrame.Angles(0, math.rad(180), 0))
local Floor2OrderNumber = Instance.new("NumberValue",Floor2)
Floor2OrderNumber.Name = "Order"
Floor2OrderNumber.Value = 2
local Floor2Height = Floor2.Height.Value
wait()
Floor3 = Stages[math.random(1, #Stages)]:Clone()
Floor3.Parent = Tower
Floor3.PrimaryPart = Floor3:FindFirstChild("Center")
Floor3:SetPrimaryPartCFrame(Floor2.Center.CFrame + Vector3.new(0, Floor2Height, 0))
Floor3:SetPrimaryPartCFrame(Floor3.Center.CFrame * CFrame.Angles(0, math.rad(180), 0))
local Floor3OrderNumber = Instance.new("NumberValue",Floor3)
Floor3OrderNumber.Name = "Order"
Floor3OrderNumber.Value = 3
local Floor3Height = Floor3.Height.Value
wait()
End.PrimaryPart = End:WaitForChild("Center")
End:SetPrimaryPartCFrame(Floor3.Center.CFrame + Vector3.new(0, Floor3Height), 0)
End:SetPrimaryPartCFrame(End.Center.CFrame * CFrame.Angles(0, math.rad(180), 0))
Debounce = false
TowerHeight.Value = Floor1Height + Floor2Height + Floor3Height + 30 * 2
ReplicatedStorage.Events.HeightEvent:FireAllClients(TowerHeight.Value)
end
-- in the ui script
for _, Section in pairs(ReversedSections) do
local Frame = Instance.new("Frame")
Frame.Size = UDim2.new(1, 0, Section.Height.Value/TowerHeight, 0)
Frame.Name = Section.Name
Frame.BorderSizePixel = 0
Frame.BackgroundColor3 = Section.PrimaryPart.Color
Frame.LayoutOrder = Section.Order.Value
Frame.Parent = script.Parent.Frame
end
1 Like
Macossaro
(Threthor)
October 23, 2021, 5:31pm
9
Modified parts of your scripts to have an Order value inside your sections so you can set them in the LayoutOrder property.
ZIndex would work in addition to this.
Vothern
(Vothern)
October 23, 2021, 5:33pm
11
Ok I’ll test these new scripts.
Vothern
(Vothern)
October 23, 2021, 5:40pm
12
Ok so with this the stages display in the opposite direction then they’re supposed to.
Macossaro
(Threthor)
October 23, 2021, 5:41pm
13
Did you set UIListLayout.VerticalAlignment to Bottom?
Vothern
(Vothern)
October 23, 2021, 5:44pm
14
Yeah but it still doesn’t work.
Vothern
(Vothern)
October 23, 2021, 5:45pm
15
For the original script it all aligns correctly but if another player joins it doesn’t for the player that joined.
Macossaro
(Threthor)
October 23, 2021, 5:46pm
16
Oh wait i got it, you should then set the LayoutOrder of the Frame to the opposite order like 3-Section.Order.Value
1 Like
Vothern
(Vothern)
October 23, 2021, 5:46pm
17
Could you send the script updated with that?
Macossaro
(Threthor)
October 23, 2021, 5:47pm
18
Frame.LayoutOrder = 3-Section.Order.Value
Vothern
(Vothern)
October 23, 2021, 5:53pm
19
Okay it works when a new server is created, haven’t tested it when another player joins the existing server yet but when the Vertical Alignment is set to Bottom, it doesn’t show the lobby:
Macossaro
(Threthor)
October 23, 2021, 5:54pm
20
Add a lobby frame the same way you did with sections but with the
Frame.LayoutOrder = -1