DataStore problem once again

In the save script you are saving your data as a table. So when it loads and you run the code:

if data then

It is actually checking if the table is not equal to nil, but not the SpeedCheck value itself. To fix this, either save it as a boolean and not a table in the Save function, or change the load line to:

SpeedCheck.Value = data and data.SpeedCheck

which is also a nice one line solution.

Also some notes:

  1. When you Connect the PlayerAdded and PlayerRemoving Event to a function, instead of doing:
game.Players.PlayerAdded:Connect(function(player)
    onPlayerJoin(player)
end)

You can instead do

game.Players.PlayerAdded:Connect(onPlayerJoin)
  1. When sending code, use 3 backticks (```) and then your code, ending with another 3 backticks. This means its formatted in the website and easier to see and modify

  2. When using Datastores, wrap any call to the datastore in a pcall, so that if it ever has an error, you can spot it and kick the player so that no data is lost.

1 Like