You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make a leaderstats script that makes a new folder and new value to put into the folder -
What is the issue? Include screenshots / videos if possible!
Script doesn’t detect that a player has joined the game -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Looked on devforum and could find no solutions
local DSS = game:GetService("DataStoreService")
local DataStore = DSS:GetDataStore("leaderstats")
function loadleaderstats(player)
print(player.Name.." has joined the game")
local leaderstats = Instance.new("Folder")
leaderstats.Parent = player
leaderstats.Name = "leaderstats"
local coins = Instance.new("IntValue")
coins.Parent = leaderstats
coins.Name = "Coins"
local loadedstats = DataStore:GetAsync(player.UserId)
if loadedstats ~= nil then
coins.Value = loadedstats[1]
else
coins.Value = 100
end
end
game.Players.PlayerAdded:Connect(loadleaderstats)