when i run the game i do not receive the IntValue aka TilesColored and leaderstats do not show up I am very confused about why its not making the IntValue
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("Tiles") game.Players.PlayerAdded:Connect(function(player) local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local tiles = Instance.new("IntValue",leader) tiles.Name = "TilesColored" tiles.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, tiles.Value) local ye = Instance.new("BrickColorValue",player) ye.Name = "colorval" ye.Value = BrickColor.Random()
The problem lies in the order of your code. Remember that data store save / load requests yield(makes your code pause until it gets a value) meaning that the code will be delayed. The result of this is that the leaderstats are not created as expected.
You should also not be using the parent argument for Instance.new
as once you parent it to the game a lot of additional changes are then needed to be replicated to the players. Follow the process, create, setup and parent last. You can parent things to leaderstats and then parent leaderstats to the game.
Lastly your yse of data stores is not safe and can error causing loss of player data. Please check wiki on how to make safe data store calls.
Example
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("Tiles") game.Player.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" local tiles = Instance.new("IntValue") tiles.Name = "TilesColored" tiles.Parent = leaderstats local ye = Instance.new("BrickColorValue") ye.Name = "colorval" ye.Value = BrickColor.Random() ye.Parent = plr leaderstats.Parent = plr -- this is not a safe way to use a data store read wiki tiles.Value = ds:GetAsync(player.UserId) or 0 end)
Hope this helps.
I LOVE U DUDE AND I WANT TO HELP YOU MAKE THE GAME AS BEST AS IT CAN GET
$$$ Front Page
Make it IntValue and make it called leaderstats DONT SAY IM WRONG BUILDERMAN TAUGHT ME