Hey, I’ll keep this simple and clear.
Today I tried making a leaderboard for a game of mine, and when I clicked ‘Play’ it wouldn’t show up in studio.
Here’s my script:
local DataStore = game:GetService(“DataStoreService”)
local PointsData = DataStore.GetOrderedDataStore(“Points”)
game.Players.PlayerAdded:Connect(function(plr)
local points = PointsData:GetAsync(plr.UserId)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
local pointsValue = Instance.new(“IntValue”, leaderstats)
pointsValue.Value = points
leaderstats.Parent = plr
end)
I feel as if this has something to do with the new player list, or is the code simply wrong?
First, please indent your code to make it a lot easier to read. Second, I recommend setting the “leaderstats” parent before setting the “points” parent. I feel as if I may have had this problem too, but other then that your script should be fine. Also being a little off topic sorry, I am not sure your data store structure is correct, is that your full script?
Edit: The folder wouldn’t even show up inside the player when I was testing my leaderboard, could be a bug with studio.
You should always check your output for errors to make sure it is working correctly. Also, don’t use the second argument of Instance.new - there’s a PSA about it
Yes, It’s my whole script.
I don’t know scripting at all, I got this script from a YouTube tutorial. So I have no idea what I’m doing, so I don’t know how to…
Ok well your data store is missing some things to properly save, try looking at AlvinBlox’s video if you haven’t. He explains everything in great detail.