local CoinsStore = DataStoreService:GetDataStore("CoinsStore")
local SpeedStore = DataStoreService:GetDataStore("SpeedStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Parent = leaderstats
local Speed = Instance.new("IntValue")
Speed.Name = "Speed"
Speed.Parent = leaderstats
local UserId = player.UserId
local data
local success, errormessage = pcall(function()
data = CoinsStore:GetAsync(UserId)
data = SpeedStore:GetAsync(UserId)
end)
if success then
Coins.Value = data
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local UserId = player.UserId
local data = player.leaderstats.Coins.Value
local data = player.leaderstats.Speed.Value
CoinsStore:SetAsync(UserId, data)
SpeedStore:SetAsync(UserId, data)
end)`
#Set something to 1 for new players in Database
4 messages · Page 1 of 1 (latest)
lets say you wanted to make the speed start as 1, under Speed.Parent = leaderstats you would do ```lua
Speed.Value = 1
But won't that make it so that the database when a person rejoins it will reset to 1
not until the data loads in