local CoinsStore = DataStoreService:GetDataStore("CoinsStore")
local SpeedStore = DataStoreService:GetDataStore("SpeedStore")
local CostStore = DataStoreService:GetDataStore("CostStore")
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.Value = 1
Speed.Parent = leaderstats
local Cost = Instance.new("IntValue")
Cost.Name = "Cost"
Cost.Value = 20
Cost.Parent = leaderstats
local UserId = player.UserId
local data
local success, errormessage = pcall(function()
data = CoinsStore:GetAsync(UserId)
data = SpeedStore:GetAsync(UserId)
data = CostStore:GetAsync(UserId)
end)
if success then
Coins.Value = data
Speed.Value = data
Cost.Value = data
else
print("There was an error whilst getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local UserId = player.UserId
local data = player.leaderstats.Coins.Value
local data = player.leaderstats.Speed.Value
local data = player.leaderstats.Cost.Value
CoinsStore:SetAsync(UserId, data)
SpeedStore:SetAsync(UserId, data)
CostStore:SetAsync(UserId, data)
end)```
#My database isn't using the values I set
15 messages · Page 1 of 1 (latest)
And how would i do that
u can find the model in toolbox
the code has like 2400 lines
And this goes in the serverscriptservice right?
Also that's a lot of code
What lines would I have to change
make a folder call it what ever u want
and put it in
sss
serverscriptservice
Alright but what lines do i change to save a speed and a coins value?