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!
Save this to a datastore and on rejoining give the floors to the player again. -
What is the issue? Include screenshots / videos if possible!
I have no clue how i would do it. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Devfourms and my own datastore system (that failed badly)
Current Code:
--Important VARs
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--ReplicatedStorage VARs
local PlayerDataFolder = ReplicatedStorage.PlayerData
local GlobalFloorFolder = ReplicatedStorage.GlobalLeaderboards.Floors
--UI VARs
local Template = script.RowTemplate
local ElevatorButton = script.Parent.Parent.ElevatorJiggle
local ServerFrame = script.Parent.ServerFrame
local GlobalFrame = script.Parent.GlobalFrame
local ServerButton = script.Parent.ServerButton
local GlobalButton = script.Parent.GlobalButton
--Leaderboard functions
local function serverSort()
for i, child in ipairs(ServerFrame:GetChildren()) do
if child.ClassName == "Frame" then
child:Destroy()
end
end
for i, child in ipairs(PlayerDataFolder:GetChildren()) do
local newRow = Template:Clone()
newRow.Name = child.Name
newRow.PlayerName.Text = child.Name
newRow.PlayerImage.Image = Players:GetUserThumbnailAsync(child.Value, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size60x60)
newRow.NumLabel.Text = child.TotalFloors.Value
if newRow.Name == "TyK214" then
newRow.Background.Visible = true
end
newRow.LayoutOrder = -child.TotalFloors.Value
newRow.Parent = ServerFrame
end
ServerFrame.CanvasSize = UDim2.new(0, 0, 0, Template.Size.Y.Offset * #PlayerDataFolder:GetChildren())
end
local function globalSort()
for i, child in ipairs(GlobalFrame:GetChildren()) do
if child.ClassName == "Frame" then
child:Destroy()
end
end
for i, child in ipairs(GlobalFloorFolder:GetChildren()) do
local newRow = Template:Clone()
newRow.Name = child.Name
newRow.PlayerName.Text = child.Name
newRow.PlayerImage.Image = Players:GetUserThumbnailAsync(child.Value, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size60x60)
newRow.NumLabel.Text = child.Num.Value
if newRow.Name == "TyK214" then
newRow.Background.Visible = true
end
newRow.LayoutOrder = -child.Num.Value
newRow.Parent = GlobalFrame
local amount = newRow.NumLabel.Text
game.ReplicatedStorage.Remotes.ChangeFloorValue:FireServer(amount)
end
GlobalFrame.CanvasSize = UDim2.new(0, 0, 0, Template.Size.Y.Offset * #GlobalFloorFolder:GetChildren())
end
--Toggle visibility
ElevatorButton.Activated:Connect(function()
script.Parent.Visible = not script.Parent.Visible
script.Ding:Play()
end)
local function toggleServerGlobal()
script.Click:Play()
ServerFrame.Visible = not ServerFrame.Visible
GlobalFrame.Visible = not GlobalFrame.Visible
if ServerFrame.Visible then
ServerButton.ImageColor3 = Color3.new(1, 1, 1)
GlobalButton.ImageColor3 = Color3.new(0, 0, 0)
else
ServerButton.ImageColor3 = Color3.new(0, 0, 0)
GlobalButton.ImageColor3 = Color3.new(1, 1, 1)
end
end
ServerButton.Activated:Connect(toggleServerGlobal)
GlobalButton.Activated:Connect(toggleServerGlobal)
--Update Leaderboards
while true do
for i=5, 60 do
wait(5)
serverSort()
if #GlobalFrame:GetChildren() == 1 then
globalSort()
end
end
globalSort()
end
It saves your value globally, but on rejoining your floors value resets to 0. How would i save the value and apply it on rejoining?