I cannot directly fix your script because I'm not familiar with your style of data saving. But you can use my style of data saving (It works perfectly).
DataStoreServiceYourDataStore:SetAsync(player.UserId.. "-AnythingYouWant", 1337)
local savedData = DataStoreServiceYourDataStore:GetAsync(player.UserId.. "-TheNameOfTheSavedDataThatYouWantToObtain")
You may also want to use UpdateAsync since SetAsync and GetAsync will be overwhelmed if you use too many of them. (But you can easily fix that by packing all data into a table and save the entire table. To get the values, simply unpack the table.)
You can study my data store script if you want to:
local DDS = game:GetService("DataStoreService"):GetDataStore("Arstotzkans'CommunismBank")
local remote1 = game:GetService("ReplicatedStorage").Remotes:WaitForChild("SaveEvent")
local remote2 = game:GetService("ReplicatedStorage").Remotes:WaitForChild("PayoutEvent")
game.Players.PlayerAdded:Connect(function(plr)
local ls = Instance.new("IntValue")
ls.Parent = plr
ls.Name = "leaderstats"
local rank = Instance.new("StringValue")
rank.Parent = ls
rank.Name = "Arstotzka"
rank.Value = plr:GetRoleInGroup(4075766)
local datafolder = Instance.new("Folder")
datafolder.Parent = plr
datafolder.Name = "DataFolder"
local money = Instance.new("IntValue")
money.Name = "Money"
money.Value = 100
money.Parent = datafolder
local npo = Instance.new("IntValue")
npo.Name = "NextPO"
npo.Parent = datafolder
npo.Value = 150
local poa = Instance.new("IntValue")
poa.Name = "POValue"
poa.Parent = datafolder
poa.Value = 100
wait(0.5)
local savedMoney = DDS:GetAsync(plr.UserId .. "-Money")
if savedMoney then
money.Value = savedMoney
end
if plr:IsInGroup(4075766) then
poa.Value = 150
end
if plr:GetRankInGroup(4075766) == 239 then
poa.Value = 200
end
if plr:GetRankInGroup(4075766) == 240 then
poa.Value = 300
end
if plr:GetRankInGroup(4075766) == 241 then
poa.Value = 250
end
if plr:GetRankInGroup(4075766) == 242 then
poa.Value = 300
end
if plr:GetRankInGroup(4075766) == 243 then
poa.Value = 350
end
if plr:GetRankInGroup(4075766) == 244 then
poa.Value = 400
end
if plr:GetRankInGroup(4075766) == 245 then
poa.Value = 450
end
if plr:GetRankInGroup(4075766) == 246 then
poa.Value = 500
end
if plr:GetRankInGroup(4075766) == 247 then
poa.Value = 600
end
if plr:GetRankInGroup(4075766) == 248 then
poa.Value = 700
end
if plr:GetRankInGroup(4075766) == 249 then
poa.Value = 800
end
if plr:GetRankInGroup(4075766) == 250 then
poa.Value = 900
end
if plr:GetRankInGroup(4075766) == 251 then
poa.Value = 1000
end
if plr:GetRankInGroup(4075766) == 253 then
poa.Value = 1500
end
if plr:GetRankInGroup(4075766) == 254 then
poa.Value = 2500
end
if plr:GetRankInGroup(4075766) == 255 then
poa.Value = 5000
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local folder = plr.DataFolder
local money = folder.Money.Value
DDS:SetAsync(plr.UserId.. "-Money", money)
end)
remote1.OnServerEvent:Connect(function(plr, code)
if code == "noyoudonotabuseourdatastoringsystemandwipepeopledatalol" then
local folder = plr.DataFolder
local money = folder.Money.Value
DDS:SetAsync(plr.UserId.. "-Money", money)
else plr:Kick("get out of my swamp")
end
end)
remote2.OnServerEvent:Connect(function(plr, code, cash)
if code == "youarenevergoingtogetrichwithexploitinglolexploitequalstodatawipelolololyouwillnevercrackthisthisisthelongestcodeandimpossibletocracklololjohndoewashereandrobloxsucksgotominecraftifyouaretoopoorforaminecraftaccountgotobrickplanetxdlololimdeadokimdonenotkthxnowbye" then
local folder = plr.DataFolder
local money = folder.Money
money.Value = money.Value + cash
else plr.DataFolder.Money.Value = 0 DDS:SetAsync(plr.UserId.. "-Money", 0) wait(2.5) plr:Kick("Congrats you have been caught exploiting and your data is WIPED! >:)")
end
end)
4 comments
Line 17. Make RobuxSpent.Value = data[1]
Maybe change one of the variables in line 7 or 15.
Yeah, I got it working
Ugh, I just posted a solution...