When The BoolValue Is True It Won’t Save
local players = game:GetService("Players")
local datastore = game:GetService("DataStoreService")
local JumpBoostDS = datastore:GetDataStore("JumpBoostDS")
game.Players.PlayerAdded:connect(function(player)
local ShopData = Instance.new("Folder")
ShopData.Name = "ShopData"
ShopData.Parent = player
local JumpBoost = Instance.new("BoolValue")
JumpBoost.Name = "JumpBoost"
JumpBoost.Parent = player.ShopData
JumpBoost.Value = JumpBoostDS:GetAsync(player.UserId) or false
JumpBoostDS:SetAsync(player.UserId, JumpBoost.Value)
JumpBoost.Changed:connect(function()
JumpBoostDS:SetAsync(player.UserId, JumpBoost.Value)
end)
end)
1 Like
I would recommend not calling a Changed
event when saving your JumpBoost.Value
, you would queue the DataStore a bunch of unnecessary times when you should be using a Autosave internal instead
And this has no pcalls why
local players = game:GetService("Players")
local datastore = game:GetService("DataStoreService")
local JumpBoostDS = datastore:GetDataStore("JumpBoostDS")
game.Players.PlayerAdded:connect(function(player)
local ShopData = Instance.new("Folder")
ShopData.Name = "ShopData"
ShopData.Parent = player
local JumpBoost = Instance.new("BoolValue")
JumpBoost.Name = "JumpBoost"
JumpBoost.Parent = player.ShopData
JumpBoost.Value = JumpBoostDS:GetAsync(player.UserId) or false
local Data
local success, whoops = pcall(function()
Data = JumpBoostDS:GetAsync(player.UserId)
end)
if success and Data then
JumpBoost.Value = Data
else
JumpBoost.Value = false
warn(whoops)
end
end)
local function AutoSave()
for _, Player in pairs(game.Players:GetPlayers()) do
local ShopData = Player:WaitForChild("ShopData", 3)
local JumpBoost = ShopData:WaitForChild("JumpBoost", 3)
local success, whoops = pcall(function()
JumpBoostDS:SetAsync(Player.UserId, JumpBoost.Value)
end)
if success then
print(Player.Name.."'s data has saved!")
else
warn(whoops)
end
end
end
while true do
wait(120)
AutoSave()
end
1 Like
It Still Won’t Work Is It Roblox Side?
You might have to play it in the roblox client (not studio)