Well, I'm trying to save tons of BoolValues for if a player owns this or that, but that doesn't matter, this is my script to save the players coins (which works):
DataStore = game:GetService("DataStoreService"):GetDataStore("Values") game.Players.PlayerAdded:connect(function(plr) local val = 0 local save = "plr-"..plr.userId local savedVals = DataStore:GetAsync(save) if savedVals then val = savedVals else val = 0 DataStore:SetAsync(save,val) end local stat = Instance.new("IntValue", plr) stat.Name = "leaderstats" local cred = Instance.new("IntValue", stat) cred.Value = val cred.Name = "Coins" local folder = Instance.new("Folder", plr) folder.Name = "AnimsChar" -- BoolVals-- local st = Instance.new("IntValue", folder) st.Name = "OwnsTest" st.Value = 1 end) game.Players.PlayerRemoving:connect(function(plr) local val = plr.leaderstats.Coins.Value local save = "plr-"..plr.userId DataStore:SetAsync(save,val) end)
This is the code to save a testing bool value (does not work):
-- Note: 0 = true, 1 = false DataStore = game:GetService("DataStoreService"):GetDataStore("OwnsTest") local t = script.Parent.Frame.Owns local p = t.Parent.Parent.Parent.Parent.Parent.Parent local b = script.Parent.Frame.TextButton b.MouseButton1Click:connect(function() local st = p.AnimsChar.OwnsTest if st.Value == 1 then st.Value = 0 elseif st.Value == 0 then t.Text = "True" end end) game.Players.PlayerAdded:connect(function(plr) local owns = 1 local save = "plr-"..plr.userId local savedVals = DataStore:GetAsync(save) if savedVals then owns = savedVals else owns = 1 DataStore:SetAsync(save, owns) end end) game.Players.PlayerRemoving:connect(function(plr) local owns = plr.AnimsChar.OwnsTest.Value local save = "plr-"..plr.userId DataStore:SetAsync(save, owns) end)