So i have this script which is suppost to save a boolvalues value
local DataStoreService = game:GetService("DataStoreService")
local ds = DataStoreService:GetDataStore("datatest")
game.Players.PlayerAdded:Connect(function(plr)
local Folder = Instance.new("Folder", plr)
Folder.Name = "test"
local BoolValue = Instance.new("BoolValue", Folder)
BoolValue.Name = "BoolValue"
local BoolValue2 = Instance.new("BoolValue", Folder)
BoolValue2.Name = "BoolValue2"
print("BoolValues succesfully created!")
local dataofuser = ds:GetAsync(plr.UserId)
if dataofuser then
BoolValue.Value = dataofuser[1]
BoolValue2.Value = dataofuser[2]
else
print("Replacing no data with new data.")
BoolValue.Value = false
BoolValue2.Value = false
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local datasave = {plr:WaitForChild("test"):WaitForChild("BoolValue").Value, plr:WaitForChild("test"):WaitForChild("BoolValue2").Value}
local success, response = pcall(function()
ds:SetAsync(plr.UserId, datasave)
end)
if success then
print("Successfully saved data of " .. plr.Name)
else
warn(response)
end
end)
im not sure if it works, but i also have these scripts:
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character
if not char then
char = plr.CharacterAdded:Wait()
end
local hum = char:FindFirstChildOfClass("Humanoid")
if hum then
local testFolder = plr:FindFirstChild("test")
if testFolder then
local boolValue = testFolder:FindFirstChild("BoolValue")
if boolValue and boolValue:IsA("BoolValue") then
if boolValue.Value == true then
hum.WalkSpeed = 20
else
print("Player's BoolValue isn't set to true!")
end
else
print("BoolValue not found in 'test' folder for player.")
end
else
print("Test folder not found for player.")
end
else
print("Humanoid not found for player.")
end
end)
also this
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character
if not char then
char = plr.CharacterAdded:Wait()
end
local hum = char:FindFirstChildOfClass("Humanoid")
if hum then
local testFolder = plr:FindFirstChild("test")
if testFolder then
local boolValue = testFolder:FindFirstChild("BoolValue2")
if boolValue and boolValue:IsA("BoolValue") then
if boolValue.Value == true then
hum.JumpPower = 75
else
print("Player's BoolValue isn't set to true!")
end
else
print("BoolValue not found in 'test' folder for player.")
end
else
print("Test folder not found for player.")
end
else
print("Humanoid not found for player.")
end
end)
to shorten it, im just trying to save the boolvalue so once i purchase a power up in my game, example: 25% more jump power/speed i want it to save the speed, the scripts check if a certain boolvalue is true and if it is then they do the effects a power up is suppost to do, i also have a script that enables the boolvalue.