DataStoreService Issue, with place, UIs

Hi, i wanted to make like leaderboard Ui that shows your stats by categories (“Top Doors”, “Top Time”) so there is screenshot of “template”:


so, in conclusion it should shows your data by dataType (doors or time top, when u click either),
this it showcase just for example to understand DataStoreService and how it works for real, so like when i join to the game, i press tp button it teleports me into a “new place” here i get “data info” and tp back into main game (this one), and it shows update/save data, at the start it shows setted info “top doors” ("doors), if i cliked time/doors, it would show this data, so there are scripts:

SERVER MAIN GAME DATA SCRIPT:

local DataStoreService = game:GetService("DataStoreService")
local ts = game:GetService("TeleportService")
local players = game:GetService("Players")

local event = game:GetService("ReplicatedStorage"):FindFirstChild("event")

local doorsStore = DataStoreService:GetOrderedDataStore("Doors_DataStore")
local timeStore = DataStoreService:GetOrderedDataStore("Time_DataStore")

local function updateDataForPlayer(player)
	local success, topDoorsPages = pcall(function() return doorsStore:GetSortedAsync(false, 100) end)	
	local success2, topTimePages = pcall(function() return timeStore:GetSortedAsync(false, 100) end)
	
	if success and success2 then
		local doorsReadyData = {}
		local timeReadyData = {}
		
		for rank, entry in pairs(topDoorsPages:GetCurrentPage()) do
			local username = pcall(function() return players:GetNameFromUserIdAsync(entry.key) end) 

			if username then
				table.insert(doorsReadyData, {
					rankIndex = rank,
					playerUsername = username,
					dataValue = entry.value
				})		
			end
		end	
		
		for rank, entry in pairs(topTimePages:GetCurrentPage()) do
			local username = pcall(function() return players:GetNameFromUserIdAsync(entry.key) end) 

			if username then
				table.insert(timeReadyData, {
					rankIndex = rank,
					playerUsername = username,
					dataValue = entry.value
				})		
			end
		end
		return doorsReadyData, timeReadyData	
	end
end

game.Players.PlayerAdded:Connect(function(player)
	local joinData = player:GetJoinData()
	local tpData = joinData.TeleportData 
	
	if tpData then
		pcall(function()
			doorsStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.doorPassed or 0
				return math.max(oldValue or 0, new)
			end) 
		end)
		
		pcall(function()
			timeStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.imeSpent or 0
				return math.max(oldValue or 0, new)
			end) 
		end)

		task.wait(1)
		local doors, times = updateDataForPlayer(player)

		event:FireClient(doors, times)
	end
end)

CLIENT MAIN GAME SCRIPT: (for updating/showing data)

local players = game:GetService("Players")

local event = game:GetService("ReplicatedStorage"):FindFirstChild("event")

local screenGui = players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
local scrollingFrame = screenGui.LeaderboardFrame.ScrollingFrame
local template = scrollingFrame:WaitForChild("PlayersData")
template.Visible = false

local currentTopDoorData = {}
local currentTopTimeData = {}
local currentCheck = "doors"

local function formattedTime(seconds: number)
	return string.format("%02d:%02d", math.floor(seconds / 60), seconds % 60)
end

local function cleanData()
	for _, frame in ipairs(scrollingFrame:GetChildren()) do
		if frame:IsA("Frame") and frame ~= template then
			frame:Destroy()
		end
	end
end

local function timeCounting()
	for i = 60, 0, -1 do
		screenGui.LeaderboardFrame.countingTime.Text = formattedTime(i)
		task.wait(1)
	end
end

local function showPlayerData(dataType)
	cleanData()
	
	for _, data in ipairs(dataType) do
		local newDataFrame = template:Clone()
		newDataFrame.Parent = scrollingFrame
		newDataFrame.Visible = true
		
		newDataFrame.NumberValue.Text = data.rankIndex
		newDataFrame.PlayerNameLabel.Text = data.playerUsername or "Unknown"
		
		if currentCheck == "time" then
			newDataFrame.ValueLabel.Text = formattedTime(data.dataValue)
		else
			newDataFrame.ValueLabel.Text = tostring(data.dataValue)
		end
	end
end

for _, button in ipairs(screenGui.LeaderboardFrame:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseButton1Click:Connect(function()
			currentCheck = (button.Name == "doorbut") and "doors" or "time"
			showPlayerData(currentCheck == "doorbut" and currentTopDoorData or currentTopTimeData) 
		end)
	end
end

event.OnClientEvent:Connect(function(doorData, timeData)
	currentTopDoorData = doorData
	currentTopTimeData = timeData
	
	showPlayerData(currentCheck == "doors" and currentTopDoorData or currentTopTimeData)
end)

task.spawn(function()
	while true do
		showPlayerData(currentTopDoorData)
		timeCounting()
	end
end)

MAIN TELEPORT SERVER SCRIPT:

local ts = game:GetService("TeleportService")

local tpSignal = game:GetService("ReplicatedStorage"):FindFirstChild("tpSignal")

tpSignal.OnServerEvent:Connect(function(player)
	local success, err = pcall(function()
		return ts:TeleportAsync(96170397388301, {player})
	end)
end)


PLACE TELEPORT SERVER SCRIPT:

local ts = game:GetService("TeleportService")

local tpSignal = game:GetService("ReplicatedStorage"):FindFirstChild("tpSignal")

tpSignal.OnServerEvent:Connect(function(player, doorsPassed, timeSpent)
	local tpOptions = Instance.new("TeleportOptions")
	tpOptions:SetTeleportData({
		doorsPassed = doorsPassed,
		timeSpent = timeSpent
	})
	
	local success, err = pcall(function()
		return ts:TeleportAsync(112647346320080, {player}, tpOptions)
	end)
end)

PLACE CLIENT SCRIPT:

local players = game:GetService("Players")
local ts = game:GetService("TeleportService")

local tpSignal = game:GetService("ReplicatedStorage"):FindFirstChild("tpSignal")
local screenGui = players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")

local doorsPassed = 5
local timeSpent = 150

screenGui.TextButton.MouseButton1Click:Connect(function()
	tpSignal:FireServer(players.LocalPlayer, doorsPassed, timeSpent)
end)

i hope someone can help me with it, it;s so complesx for my mind enough and i spent time watching tutorials (to get smth new), read documentation and even used ai to check if i’m go in correct way.. seems no :frowning: (*srry for my english if it’s bad, it’s not my native language.)

I think I see a few issues here that might be causing problems.

First thing: in your server script where you handle the teleport data, you have a typo. Look at this line:

local new = tpData.imeSpent or 0

It says “imeSpent” but should be “timeSpent”, that’s why your time data probably isn’t saving correctly.

Also in your client script, there’s a logic issue with the button checking:

showPlayerData(currentCheck == "doorbut" and currentTopDoorData or currentTopTimeData)

You’re comparing to “doorbut” but earlier you set currentCheck to either “doors” or “time”. So this condition would never be true. You probably want:

showPlayerData(currentCheck == "doors" and currentTopDoorData or currentTopTimeData)

Another thing: when you fire the event to the client, you’re only passing the data but not the player:

event:FireClient(doors, times)

should be:

event:FireClient(player, doors, times)

FireClient always needs the player as the first argument

Oh, and one more thing: in your GetNameFromUserIdAsync calls, you’re using pcall wrong. pcall returns a success boolean first, then the actual result. So it should be:

local success, username = pcall(function() return players:GetNameFromUserIdAsync(entry.key) end)

if success and username then

Otherwise you’re just checking if the pcall succeeded, not if you actually got a username back

oh, a few things i haven’t noticed, i blind for real, let me check it out to if it obly one problem here

yep, due to this little messed things it wanst working, now it does, but here what i see, top doors i dont see any data, but in top time i see:


and i don’t know but counter is crashed after i waas clicking on this buttons lol (ill try to fix counter)*

issue in developer console (for now i don’t know what is the fault in these lines)*

So for the top doors showing nothing, check your datastore in the main game. Maybe there’s just no data saved yet for doors. You can maybe try going through the teleport process a few times to actually save some door data, then check if it shows up.

For that error you’re getting about “Unable to assign property Text… string expected, got boolean”, that’s happening in your showPlayerData function. The issue is this line:

newDataFrame.PlayerNameLabel.Text = data.playerUsername or "Unknown"

The problem is data.playerUsername might be returning a boolean (true/false) instead of a string because of how you’re handling the pcall.

In your server script, you can try to change the username fetching to:

for rank, entry in pairs(topDoorsPages:GetCurrentPage()) do
    local success, username = pcall(function() 
        return players:GetNameFromUserIdAsync(entry.key) 
    end)

    if success and username then
        table.insert(doorsReadyData, {
            rankIndex = rank,
            playerUsername = tostring(username),
            dataValue = entry.value
        })        
    end
end

tostring(username) will make sure it’s always a string. Do the same for the time data loop too.

For the counter crashing when clicking buttons, I think it’s because your while loop is trying to show data that might not exist yet. Maybe add a check like:

task.spawn(function()
    while true do
        if #currentTopDoorData > 0 then
            showPlayerData(currentTopDoorData)
        end
        timeCounting()
    end
end)
1 Like

ye, thats correct, while u was replying i fixed counter and some issues in data, etc, but the main issues still wasnt solved, yep what u r saying here this is correct, i’ve already changed that u said rn, but the main problem that im laughing is that, for example, data :

local doorsPassed = 5
local timeSpent = 150


the reason why it looks like that I have already setted up data before, or something i changed that values are different, but its not cuz here is 150 secs, but we got 5 secs, so how to fix this issue?

Ohhh wait I think I see the problem now. Look at your client script in the main game, you have this part at the very end:

task.spawn(function()
    while true do
        showPlayerData(currentTopDoorData)
        timeCounting()
    end
end)

This is running in a loop and calling showPlayerData(currentTopDoorData) every time, which is always showing the doors data. But then timeCounting() runs for 60 seconds counting down. So when you click the top time button, it switches to time data for a second, but then the loop immediately runs again and forces it back to doors data. That’s why you’re seeing the wrong values.

You need to change that loop to respect the currentCheck variable:

task.spawn(function()
    while true do
        local dataToShow = currentCheck == "doors" and currentTopDoorData or currentTopTimeData
        if #dataToShow > 0 then
            showPlayerData(dataToShow)
        end
        timeCounting()
    end
end)

Now it’ll check which category you’re viewing and show the right data each time the loop runs.

1 Like

hmm, one min, cuz here is very interesting thing due to im confused as he11, ill write

so, i add a few “people” to check how it works, like how im understand, it sorts correctly, but i only see myself or it should be liek this?, also why when im join to the game i dont see my data obly when im joing through the place after that i see my data and yes i changed what u said even change this:

local new = tpData.doorPassed or 0

to this:

local new = tpData.doorsPassed or 0

and nothing changed too much


new scripts"

local DataStoreService = game:GetService("DataStoreService")
local ts = game:GetService("TeleportService")
local players = game:GetService("Players")

local event = game:GetService("ReplicatedStorage"):FindFirstChild("event")

local doorsStore = DataStoreService:GetOrderedDataStore("Doors_DataStore")
local timeStore = DataStoreService:GetOrderedDataStore("Time_DataStore")

local function updateDataForPlayer(player)
	local success, topDoorsPages = pcall(function() return doorsStore:GetSortedAsync(false, 100) end)	
	local success2, topTimePages = pcall(function() return timeStore:GetSortedAsync(false, 100) end)
	
	if success and success2 then
		local doorsReadyData = {}
		local timeReadyData = {}
		
		for rank, entry in pairs(topDoorsPages:GetCurrentPage()) do
			local success, username = pcall(function() return players:GetNameFromUserIdAsync(entry.key) end) 

			if success and username then
				table.insert(doorsReadyData, {
					rankIndex = rank,
					playerUsername = tostring(username),
					dataValue = entry.value
				})	
			end
		end	
		
		for rank, entry in pairs(topTimePages:GetCurrentPage()) do
			local success, username = pcall(function() return players:GetNameFromUserIdAsync(entry.key) end) 

			if success and username then
				table.insert(timeReadyData, {
					rankIndex = rank,
					playerUsername = tostring(username),
					dataValue = entry.value
				})	
			end
		end
		return doorsReadyData, timeReadyData	
	end
end

game.Players.PlayerAdded:Connect(function(player)
	local joinData = player:GetJoinData()
	local tpData = joinData.TeleportData 
	
	if tpData then
		pcall(function()
			doorsStore:SetAsync("User_1", 45)
			doorsStore:SetAsync("User_2", 10)
			doorsStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.doorsPassed or 0
				return math.max(oldValue or 0, new)
			end) 
		end)
		
		pcall(function()
			timeStore:SetAsync("User_1", 245)
			timeStore:SetAsync("User_2", 84)
			timeStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.timeSpent or 0
				return math.max(oldValue or 0, new)
			end) 
		end)

		task.wait(1)
		local doors, times = updateDataForPlayer(player)
		event:FireClient(player, doors, times)
	end
end)

client:

local players = game:GetService("Players")

local event = game:GetService("ReplicatedStorage"):FindFirstChild("event")

local screenGui = players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
local scrollingFrame = screenGui.LeaderboardFrame.ScrollingFrame
local template = scrollingFrame:WaitForChild("PlayersData")
template.Visible = false

local currentTopDoorData = {}
local currentTopTimeData = {}
local currentCheck = "doors"

local function formattedTime(seconds: number)
	return string.format("%02d:%02d", math.floor(seconds / 60), seconds % 60)
end

local function cleanData()
	for _, frame in ipairs(scrollingFrame:GetChildren()) do
		if frame:IsA("Frame") and frame ~= template then
			frame:Destroy()
		end
	end
end

local function timeCounting()
	for i = 60, 0, -1 do
		screenGui.LeaderboardFrame.countingTime.Text = formattedTime(i)
		task.wait(1)
	end
end

local function showPlayerData(dataType)
	cleanData()
	
	for _, data in ipairs(dataType) do
		local newDataFrame = template:Clone()
		newDataFrame.Parent = scrollingFrame
		newDataFrame.Visible = true
		
		newDataFrame.NumberValue.Text = data.rankIndex
		newDataFrame.PlayerNameLabel.Text = data.playerUsername or "Unknown"
		
		if currentCheck == "time" then
			newDataFrame.ValueLabel.Text = formattedTime(data.dataValue)
		else
			newDataFrame.ValueLabel.Text = data.dataValue
		end
	end
end

for _, button in ipairs(screenGui.LeaderboardFrame:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseButton1Click:Connect(function()			
			currentCheck = (button.Name == "doorbut") and "doors" or "time"
			showPlayerData(currentCheck == "doors" and currentTopDoorData or currentTopTimeData) 
		end)
	end
end

event.OnClientEvent:Connect(function(doorData, timeData)
	currentTopDoorData = doorData
	currentTopTimeData = timeData
	
	showPlayerData(currentCheck == "doors" and currentTopDoorData or currentTopTimeData)
end)

task.spawn(function()
	while true do
		local dataShow = currentCheck == "doors" and currentTopDoorData or currentTopTimeData
		if #dataShow > 0 then
			showPlayerData(dataShow)
		end
		timeCounting()
	end
end)

place script (just to see)

local players = game:GetService("Players")
local ts = game:GetService("TeleportService")

local tpSignal = game:GetService("ReplicatedStorage"):FindFirstChild("tpSignal")
local screenGui = players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")

local doorsPassed = 12
local timeSpent = 45

screenGui.TextButton.MouseButton1Click:Connect(function()
	tpSignal:FireServer(players.LocalPlayer, doorsPassed, timeSpent)
end)

You only see yourself right now because you’re using User_1 and User_2 as test data, but those aren’t real user IDs. When you call GetNameFromUserIdAsync("User_1") it’s gonna fail because User_1 isn’t a valid user ID number. So those entries get skipped and you only see actual players who have real data.

If you wanna test with fake data, you need to use real user IDs. Like instead of:

doorsStore:SetAsync("User_1", 45)

Use actual Roblox user IDs:

doorsStore:SetAsync("12345678", 45)

Then, you don’t see data when you first join, because of this check:

if tpData then

The leaderboard only updates when you have teleport data. When you first join normally without teleporting, tpData is nil, so the whole thing gets skipped. You need to also load the leaderboard data for everyone on join, not just people with teleport data.

Try changing your PlayerAdded to this:

game.Players.PlayerAdded:Connect(function(player)
	local joinData = player:GetJoinData()
	local tpData = joinData.TeleportData 
	
	if tpData then
		pcall(function()
			doorsStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.doorsPassed or 0
				return math.max(oldValue or 0, new)
			end) 
		end)
		
		pcall(function()
			timeStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.timeSpent or 0
				return math.max(oldValue or 0, new)
			end) 
		end)
	end

	task.wait(1)
	local doors, times = updateDataForPlayer(player)
	event:FireClient(player, doors, times)
end)

Now it’ll load the leaderboard for everyone who joins, and if they came from a teleport it’ll update their data first.

Also remove those SetAsync lines for User_1 and User_2 unless you’re using real user IDs for testing.

1 Like

oh, okay, it doesnt matter so much, i need fix data info why i see data that i shouldnt see :frowning:

Maybe the issue is that you’re setting doorsPassed to 12 and timeSpent to 45 seconds. So when you look at top time in the leaderboard, it’s showing 00:12 which is 12 seconds, not 45 seconds. That’s because it’s showing the doors value (12) in the time column instead of the time value (45). The issue is probably in how the data is being sent. If that looks right, then the problem might be in how you’re displaying it.

Wait actually, can you show me what exactly you’re seeing that you shouldn’t be seeing? Like which numbers are wrong?

I checked every line several times and didn’t find anything that wouldn’t work, everything should work actually, the problem is that the datastore looks weird, i add new value, like for UpdateAsync(), whne i get info from the place (data, that will be replaced by new one:

local doorsPassed = math.random(1, 50)
local timeSpent = math.random(25, 150)

after that i send this by remote event:

screenGui.TextButton.MouseButton1Click:Connect(function()
	tpSignal:FireServer(players.LocalPlayer, doorsPassed, timeSpent)
end)

on the server side im sending data into the main game (is should send two values and it should saves (when we’re in the main game) ) :

tpSignal.OnServerEvent:Connect(function(player, doorsPassed, timeSpent)
	local tpOptions = Instance.new("TeleportOptions")
	tpOptions:SetTeleportData({
		maxDoor = doorsPassed,
		maxTime = timeSpent
	})
	
	local success, err = pcall(function()
		return ts:TeleportAsync(112647346320080, {player}, tpOptions)
	end)
end)

and as i said before, i didn’t find any mistake or something that can goes wrong in some way i dont understand why it looks very weird :confused:

(client and server side scripts try to check it maybe i js blind and didn’t noticed smth)

server:

local DataStoreService = game:GetService("DataStoreService")
local ts = game:GetService("TeleportService")
local players = game:GetService("Players")

local event = game:GetService("ReplicatedStorage"):FindFirstChild("event")

local doorsStore = DataStoreService:GetOrderedDataStore("Doors_DataStore")
local timeStore = DataStoreService:GetOrderedDataStore("Time_DataStore")

local function updateDataForPlayer(player)
	local success, topDoorsPages = pcall(function() return doorsStore:GetSortedAsync(false, 100) end)	
	local success2, topTimePages = pcall(function() return timeStore:GetSortedAsync(false, 100) end)
	
	if success and success2 then
		local doorsReadyData = {}
		local timeReadyData = {}
		
		for rank, entry in pairs(topDoorsPages:GetCurrentPage()) do
			local success, username = pcall(function() return players:GetNameFromUserIdAsync(entry.key) end) 

			if success and username then
				table.insert(doorsReadyData, {
					rankIndex = rank,
					playerUsername = tostring(username),
					dataValue = entry.value
				})	
			end
		end	
		
		for rank, entry in pairs(topTimePages:GetCurrentPage()) do
			local success, username = pcall(function() return players:GetNameFromUserIdAsync(entry.key) end) 

			if success and username then
				table.insert(timeReadyData, {
					rankIndex = rank,
					playerUsername = tostring(username),
					dataValue = entry.value
				})	
			end
		end
		return doorsReadyData, timeReadyData	
	end
end

game.Players.PlayerAdded:Connect(function(player)
	local joinData = player:GetJoinData()
	local tpData = joinData.TeleportData 

	if tpData then		
		pcall(function()
			doorsStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.maxDoor or 0
				return math.max(oldValue or 0, new)
			end) 
		end)

		pcall(function()
			timeStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.maxTime or 0
				return math.max(oldValue or 0, new)
			end) 
		end)
	end

	task.wait(1)
	local doors, times = updateDataForPlayer(player)
	event:FireClient(player, doors, times)
end)

client:

local players = game:GetService("Players")

local event = game:GetService("ReplicatedStorage"):FindFirstChild("event")

local screenGui = players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
local scrollingFrame = screenGui.LeaderboardFrame.ScrollingFrame
local template = scrollingFrame:WaitForChild("PlayersData")
template.Visible = false

local currentTopDoorData = {}
local currentTopTimeData = {}
local currentCheck = "doors"

local function formattedTime(seconds: number)
	return string.format("%02d:%02d", math.floor(seconds / 60), seconds % 60)
end

local function cleanData()
	for _, frame in ipairs(scrollingFrame:GetChildren()) do
		if frame:IsA("Frame") and frame ~= template then
			frame:Destroy()
		end
	end
end

local function timeCounting()
	for i = 60, 0, -1 do
		screenGui.LeaderboardFrame.countingTime.Text = formattedTime(i)
		task.wait(1)
	end
end

local function showPlayerData(dataType)
	cleanData()
	
	for _, data in ipairs(dataType) do
		local newDataFrame = template:Clone()
		newDataFrame.Parent = scrollingFrame
		newDataFrame.Visible = true
		
		newDataFrame.NumberValue.Text = data.rankIndex
		newDataFrame.PlayerNameLabel.Text = data.playerUsername or "Unknown"
		
		if currentCheck == "time" then
			newDataFrame.ValueLabel.Text = formattedTime(data.dataValue)
		else
			newDataFrame.ValueLabel.Text = data.dataValue
		end
	end
end

for _, button in ipairs(screenGui.LeaderboardFrame:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseButton1Click:Connect(function()			
			currentCheck = (button.Name == "doorbut") and "doors" or "time"
			showPlayerData(currentCheck == "doors" and currentTopDoorData or currentTopTimeData) 
		end)
	end
end

event.OnClientEvent:Connect(function(doorData, timeData)
	currentTopDoorData = doorData
	currentTopTimeData = timeData
	
	showPlayerData(currentCheck == "doors" and currentTopDoorData or currentTopTimeData)
end)

task.spawn(function()
	while true do
		local dataShow = currentCheck == "doors" and currentTopDoorData or currentTopTimeData
		if #dataShow > 0 then
			showPlayerData(dataShow)
		end
		timeCounting()
	end
end)

and what i get(WHAT IS THIS!!!?) :frowning:

door’s top:

time top:
image

also maybe, i think that issue can be in the server side palce script like this:

local doorsPassed = math.random(1, 50)
local timeSpent = math.random(25, 150)

screenGui.TextButton.MouseButton1Click:Connect(function()
	tpSignal:FireServer(players.LocalPlayer, doorsPassed, timeSpent)
end)

like we shouldn’t send “player” cuz it causes the issues (as i know, like it already fire the player, so it will fire it twice and looks like this:

screenGui.TextButton.MouseButton1Click:Connect(function()
	tpSignal:FireServer(player, player, doorsPassed, timeSpent)
end)

(maybe, im not sure :frowning: ), and like will be better if maybe we just pass this:

local doorsPassed = math.random(1, 50)
local timeSpent = math.random(25, 150)
print(doorsPassed, timeSpent)

screenGui.TextButton.MouseButton1Click:Connect(function()
	tpSignal:FireServer(doorsPassed, timeSpent)
end)

and info we put here, idk rlly ?

tpSignal.OnServerEvent:Connect(function(player, doorsPassed, timeSpent)	
	local tpOptions = Instance.new("TeleportOptions")
	tpOptions:SetTeleportData({
		maxDoor = doorsPassed,
		maxTime = timeSpent
	})
	
	local success, err = pcall(function()
		return ts:TeleportAsync(112647346320080, {player}, tpOptions)
	end)
end)

so, i fiex a lot of issues only that i need right now ithink that it doesnt display player’s skin id kwhy cuz when i tested in main gameplay (other game it applies, now like there are like 4 players it doesnt apply them (

client:

local players = game:GetService("Players")

local event = game:GetService("ReplicatedStorage"):FindFirstChild("event")
local applyEvent = game:GetService("ReplicatedStorage"):FindFirstChild("applyEvent")

local screenGui = players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
local scrollingFrame = screenGui.LeaderboardFrame.ScrollingFrame
local template = scrollingFrame:WaitForChild("PlayersData")
template.Visible = false

local currentTopDoorData = {}
local currentTopTimeData = {}
local currentCheck = "doors"

local function formattedTime(seconds: number)
	return string.format("%02d:%02d", math.floor(seconds / 60), seconds % 60)
end

local function cleanData()
	for _, frame in ipairs(scrollingFrame:GetChildren()) do
		if frame:IsA("Frame") and frame ~= template then
			frame:Destroy()
		end
	end
end

local function timeCounting()
	for i = 60, 0, -1 do
		screenGui.LeaderboardFrame.countingTime.Text = formattedTime(i)
		task.wait(1)
	end
end

local function coloredRankIndex(label, index)
	if index == 1 then
		label.TextColor3 = Color3.fromRGB(255, 198, 83)
	elseif index == 2 then
		label.TextColor3 = Color3.fromRGB(171, 175, 225)
	elseif index == 3 then
		label.TextColor3 = Color3.fromRGB(167, 91, 84)
	else
		label.TextColor3 = Color3.fromRGB(255, 255, 255)
	end
end

local function showPlayerData(dataType)
	cleanData()
	
	for _, data in ipairs(dataType) do
		local newDataFrame = template:Clone()
		newDataFrame.Parent = scrollingFrame
		newDataFrame.Visible = true
		
		newDataFrame.NumberValue.Text = data.rankIndex
		newDataFrame.PlayerNameLabel.Text = data.playerUsername or "Unknown"
			
		coloredRankIndex(newDataFrame.NumberValue, data.rankIndex)
			
		if currentCheck == "time" then
			newDataFrame.ValueLabel.Text = formattedTime(data.dataValue)
		else
			newDataFrame.ValueLabel.Text = data.dataValue
		end
		
		applyEvent:FireServer(newDataFrame.ViewportFrame)	
	end
end

for _, button in ipairs(screenGui.LeaderboardFrame:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseButton1Click:Connect(function()			
			currentCheck = (button.Name == "doorbut") and "doors" or "time"
			showPlayerData(currentCheck == "doors" and currentTopDoorData or currentTopTimeData) 
		end)
	end
end

event.OnClientEvent:Connect(function(doorData, timeData)
	currentTopDoorData = doorData
	currentTopTimeData = timeData
	
	showPlayerData(currentCheck == "doors" and currentTopDoorData or currentTopTimeData)
end)

task.spawn(function()
	while true do
		local dataShow = currentCheck == "doors" and currentTopDoorData or currentTopTimeData
		if #dataShow > 0 then
			showPlayerData(dataShow)
		end
		timeCounting()
	end
end)

server:

local DataStoreService = game:GetService("DataStoreService")
local ts = game:GetService("TeleportService")
local players = game:GetService("Players")

local event = game:GetService("ReplicatedStorage"):FindFirstChild("event")
local applyEvent = game:GetService("ReplicatedStorage"):FindFirstChild("applyEvent")

local doorsStore = DataStoreService:GetOrderedDataStore("Doors_DataStore")
local timeStore = DataStoreService:GetOrderedDataStore("Time_DataStore")

doorsStore:SetAsync("978808592", 60)
timeStore:SetAsync("978808592", 566)

doorsStore:SetAsync("1695120376", 23)
timeStore:SetAsync("1695120376", 345)

doorsStore:SetAsync("4810398284", 45)
timeStore:SetAsync("4810398284", 289)

local function updateDataForPlayer(player)
	local success, topDoorsPages = pcall(function() return doorsStore:GetSortedAsync(false, 100) end)	
	local success2, topTimePages = pcall(function() return timeStore:GetSortedAsync(false, 100) end)
	
	if success and success2 then
		local doorsReadyData = {}
		local timeReadyData = {}
		
		for rank, entry in pairs(topDoorsPages:GetCurrentPage()) do
			local success, username = pcall(function() return players:GetNameFromUserIdAsync(entry.key) end) 

			if success and username then
				table.insert(doorsReadyData, {
					rankIndex = rank,
					playerUsername = tostring(username),
					dataValue = entry.value,
				})	
			end
		end	
		
		for rank, entry in pairs(topTimePages:GetCurrentPage()) do
			local success, username = pcall(function() return players:GetNameFromUserIdAsync(entry.key) end) 

			if success and username then
				table.insert(timeReadyData, {
					rankIndex = rank,
					playerUsername = tostring(username),
					dataValue = entry.value,
				})	
			end
		end
		
		return doorsReadyData, timeReadyData	
	end
end

applyEvent.OnServerEvent:Connect(function(player, viewportFrame)
	local userId = player.UserId	
	local success, description = pcall(function()
		return game.Players:GetHumanoidDescriptionFromUserIdAsync(userId)
	end)

	if success and description then
		local playerRig = workspace:WaitForChild("PlayerRig")
		local humanoid = playerRig:FindFirstChildOfClass("Humanoid")
		humanoid:ApplyDescriptionAsync(description)	

		task.wait(1)
		local clone = playerRig:Clone()
		clone.Parent = viewportFrame
	end
end)

game.Players.PlayerAdded:Connect(function(player)
	local joinData = player:GetJoinData()
	local tpData = joinData.TeleportData 

	if tpData then			
		pcall(function()
			doorsStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.maxDoor or 0
				return math.max(oldValue or 0, new)
			end) 
		end)

		pcall(function()
			timeStore:UpdateAsync(tostring(player.UserId), function(oldValue)
				local new = tpData.maxTime or 0
				return math.max(oldValue or 0, new)
			end) 
		end)
	end

	task.wait(1)
	
	local doors, times = updateDataForPlayer(player)
	event:FireClient(player, doors, times)
end)


@Collafranca did you see what I said, hmm?