I’ve attempted to try and do a data save code, but the data would not save and I don’t know why
This is my first time attempting this without any help and I have no idea what is wrong with it, so can anyone spot any mistakes within the code? Thank you for reading
the variable “data” is a table, so it looks like this:
local data = {}
so when you set the value of the boolvalue to data you are setting to a table, which isn’t possible.
so instead you should do
SpeedCheck.Value = data.SpeedCheck
also when saving you should do this instead:
this wont work because of how your code is written, this is an example of how it would look.
local function onPlayerLeave(Player)
local succ, err = pcall(function()
local playerUserId = "Player_".. Player.UserId
local speedcheckValue = Player.BlackMarketThings.SpeedCheck.Value
local dataToSave = {
SpeedCheck = speedcheckValue,
}
playerData:SetAsync(playerUserId, dataToSave)
end)
if not succ then
warn("Could not save data! Error message:", err) -- will tell you the error
end
end
You need a way to get their SpeedCheck value, the code I provided wont work because it assumes that the BlackMarketThings folder is in their player
when saving data, make sure you are saving a table like the code I provided
you need a way to access that player’s SpeedCheck value. I’d put the value inside of their player.
(because yours creates a new value for each player that joins but they are all named the same, so you end up with 30 values in BlackMarketThings with the same name and no way to know whos value is who’s)