So basically what I’m going for is a datastore that saves if a bool value is true or false, the developer page only seems to cover leaderstats so instead I tried just having a leader stats datastore but with a boolvalue in replicated storage, the problem is it isn’t saving it and when you restart the game its false again, there could be several reasons why it isn’t working it could be because if I wanted it to be a bool value it’d need to be written pretty differently but I’m not too sure
code
local DataStoreService = game:GetService("DataStoreService")
local CCrackerSave = DataStoreService:GetDataStore("CCrackerSave")
local CCrackerInstallRemote = game.ReplicatedStorage.CCrackerInstall
game.Players.PlayerAdded:Connect(function(player)
local IsCCrackerInstalled = game.ReplicatedStorage.IsCCrackerInstalled.Value
local data
local success, errormessage = pcall(function()
data = CCrackerSave:GetAsync(player.UserId.."-IsCCrackerInstalled")
end)
if success then
IsCCrackerInstalled = data
else
print("Couldn't save...")
warn(errormessage)
end
end)
CCrackerInstallRemote.OnServerEvent:Connect(function(player)
game.ReplicatedStorage.IsCCrackerInstalled.Value = true
local success, errormessage = pcall(function()
CCrackerSave:SetAsync(player.UserId.."-IsCCrackerInstalled",game.ReplicatedStorage.IsCCrackerInstalled.Value)
end)
if success then
print("CCrackerInstall Saved")
else
print("CCrackerInstall Failed..")
warn(errormessage)
end
end)
Not sure how I’d start to fix it but anything helps
What you are currently doing is sharing one bool value in replicated storage for all players. You can put a bool value inside the player when they join the game if you desire, then you can save the value of that bool value to the datastore whenever needed.
Still doesn’t save but heres the new code incase I did something wrong
local DataStoreService = game:GetService("DataStoreService")
local CCrackerSave = DataStoreService:GetDataStore("CCrackerSave")
local CCrackerInstallRemote = game.ReplicatedStorage.CCrackerInstall
game.Players.PlayerAdded:Connect(function(player)
local IsCCrackerInstalled = Instance.new("BoolValue")
IsCCrackerInstalled.Name = "IsCCrackerInstalled"
IsCCrackerInstalled.Parent = player
local data
local success, errormessage = pcall(function()
data = CCrackerSave:GetAsync(player.UserId.."-IsCCrackerInstalled")
end)
if success then
IsCCrackerInstalled = data
else
print("Couldn't save...")
warn(errormessage)
end
end)
CCrackerInstallRemote.OnServerEvent:Connect(function(player)
game.ReplicatedStorage.IsCCrackerInstalled.Value = true
local success, errormessage = pcall(function()
CCrackerSave:SetAsync(player.UserId.."-IsCCrackerInstalled",player.IsCCrackerInstalled.Value)
end)
if success then
print("CCrackerInstall Saved")
else
print("CCrackerInstall Failed..")
warn(errormessage)
end
end)
I do, infact, have studio access to api services enabled, its not even giving me an error it just prints my successful message and casually doesn’t work
this gave me an error saying “attempt to call a string value” heres the code incase I put the tostring in the wrong place
local DataStoreService = game:GetService("DataStoreService")
local CCrackerSave = DataStoreService:GetDataStore("CCrackerSave")
local CCrackerInstallRemote = game.ReplicatedStorage.CCrackerInstall
game.Players.PlayerAdded:Connect(function(player)
local CCracker = Instance.new("Folder")
CCracker.Name = "CCracker"
CCracker.Parent = player
local IsCCrackerInstalled = Instance.new("BoolValue")
IsCCrackerInstalled.Name = "IsCCrackerInstalled"
IsCCrackerInstalled.Parent = player.CCracker
local data = DataStoreService:GetDataStore(tostring(player.UserId))
local success, errormessage = pcall(function()
data = CCrackerSave:GetAsync(tostring(player.UserId)"-IsCCrackerInstalled")
end)
if success then
IsCCrackerInstalled = data
else
print("Couldn't save...")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
CCrackerSave:SetAsync(tostring(player.UserId)"-IsCCrackerInstalled", player.CCracker.IsCCrackerInstalled.Value)
wait(3)
end)
if success then
print("CCrackerInstall Saved")
else
print("CCrackerInstall Failed..")
warn(errormessage)
wait(3)
end
end)