Guys i looked up how to do matchmaking but the leader board doesnt work.
the code below just shows Value and a "-" on the leaderboard.
could someone say what's going on? why is it wrong? (btw it should say rating and 1500)
local ratingData = game:GetService("DataStoreService"):GetDataStore("RatingData")
-- Handle player joining the game. If they are a new player we need to give them
-- an initial rank. For existing players we need to fetch their rank from our
-- DataStore. Lastly, we want to display the player's rank in the Leaderboard
game.Players.PlayerAdded:connect(function(player)
local playerData = {}
-- Create a default rating of 1500 if the player's data is not in the DataStore
ratingData:UpdateAsync(player.userId, function(oldValue)
local newValue = oldValue
if not newValue then
newValue = { Rating = 1500 }
end
return newValue
end)
playerData.Score = ratingData:GetAsync(tostring(player.userId)).Rating
-- Display rating in Leaderboard
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local displayRating = Instance.new("IntValue", leaderstats)
displayRating.Name = "Rating"
displayRating.Value = playerData.Score
end) |