Hello! Basically I am creating a game with Cash and Jobs, and while testing the DataStores I have found a bug that my StringValue isn't saving to my datastore! Is their a bug in my Leaderstats code? There are no error outputs either.
ds = game:GetService("DataStoreService")
ds1 = ds:GetDataStore("RoLifeDataStoreForCash")
ds2 = ds:GetDataStore("RoLifeDataStoreForJobs")
game.Players.PlayerAdded:connect(function(p)
local stats = Instance.new("Folder", p)
stats.Name = "leaderstats"
local money = Instance.new("IntValue", stats)
money.Name = "Money"
money.Value = ds1:GetAsync(p.userId) or 200
local job = Instance.new("StringValue", stats)
job.Name = "Job"
job.Value = ds2:GetAsync(p.userId) or "None"
wait(2)
if job.Value == "Influencer" then
game.ReplicatedStorage.rPhone:Clone().Parent = p.Backpack
end
job.Changed:connect(function(p)
wait(0.2)
ds2:SetAsync(p.userId, p.leaderstats.Job.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(p)
ds1:SetAsync(p.userId, p.leaderstats.Money.Value)
end)

4 comments
Oh heck no, don't use changed and then save stuff, that is very unwise and ugly, Also don't use multiple datastores, also add bindtoclose, also, userId is deprecated, use UserId, also, "Instance.new("IntValue, stats) is deprecated
also don't use or "None"
Thank you mate, is it because I used multiple datastores? Or?
I don't see anything wrong with using
or "None"