Hey All! What is the parameter’s value on the function? I’ve noticed that the code doesn’t work whenever I don’t state the leaderstats.parent onto the ‘player’ variable.
local dataStoreService = game:GetService("DataStoreService")
local myDataStore = dataStoreService:GetDataStore("myDataSore")
game.Players.PlayerAdded:Connect(function(player)
local leaderStats = Instance.new("Folder")
leaderStats.Name = "leaderstats"
leaderStats.Parent = player
end)
But I made some notes to explain the lines of code:
game.Players.PlayerAdded:Connect(function(player) -- a player was added
local leaderStats = Instance.new("Folder") -- create a folder
leaderStats.Name = "leaderstats" -- name it leaderstats
leaderStats.Parent = player -- put it into the Player
end)
The player parameter basically means the player that has been added to the game.
In the coding example you have provided, you are creating a folder named ‘leaderstats’ and you are parenting it to the player that has been added to the game.