I'm unsure about whats happening. One second my data store was working and now its not. If anyone knows whats wrong and can help me that would be great.
local Data = game:GetService("DataStoreService"):GetDataStore("CashData") game.Players.PlayerAdded:Connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = plr.Name local cash = Instance.new("IntValue",folder) cash.Name = "Cash" local income = Instance.new("IntValue",folder) income.Name = "Income" local SavedItems = Data:GetAsync(plr.UserId) if SavedItems then cash.Value = SavedItems.Cash else cash.Value = 0 end end) game.Players.PlayerRemoving:Connect(function(plr) local saving = {["Cash"] = plr:FindFirstChild(plr.Name).Cash.Value} Data:SetAsync(plr.userId,saving) end)
try this:
```local Data = game:GetService("DataStoreService"):GetDataStore("CashData")
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = plr.Name
local cash = Instance.new("IntValue",folder)
cash.Name = "Cash"
local income = Instance.new("IntValue",folder)
income.Name = "Income"
local SavedItems = Data:GetAsync(plr.UserId) or 0
if SavedItems then
cash.Value = SavedItems.Cash
else
cash.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local saving = {["Cash"] = plr:FindFirstChild(plr.Name).Cash.Value}
Data:SetAsync(plr.userId,saving)
end)```
could it be syntax error?
my code usually looks like this:
saving = {Cash = plr:FindFirstChild(plr.Name).Cash.Value}