I'm making a data store script and I can't seem to see an error. There is no error in the output either. Here is my script, pls fix if possible.
local DSS = game:GetService("DataStoreService")
local cashDSS = DSS:GetDataStore("CurrencyStore")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local Currency = Instance.new("IntValue", leaderstats)
Currency.Name = "Bucks"
local data
local success, errormsg = pcall(function()
data = cashDSS:GetAsync(plr.UserId.."-Bucks")
end)
if success then
Currency.Value = data
print("data of "..plr.Name.." has been loaded") --//Prints this
end
if errormsg then
print("Data of "..plr.Name.." couldn't be loaded") --//I'm assuming this works
warn(errormsg)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormsg = pcall(function()
cashDSS:SetAsync(plr.UserId.."-Bucks", plr.leaderstats.Bucks.Value)
end)
if success then
print("Successfully saved data of "..plr.Name) --//Doesn't print
else
print("Data could not be saved of "..plr.Name) --//Doesn't print
warn(errormsg) --//Doesn't warn
end
end)
I appreciate your time and effort. Thanks for helping.

1 comment
Thanks I'll try it out now