Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this work? (Save BoolValue on server)

Hey guys! I'm trying to figure why doesn't this save script work. It doesnt send any error back but the value is set to false each time I rejoin/test the game

local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService") -- Getting data store service

Players.PlayerAdded:connect(function(player)
    local TrackersData = DataStoreService:GetDataStore(player.UserId.."Trackers") -- Getting data store
    local LevelTracker = Instance.new("Folder")
    LevelTracker.Parent = player
    LevelTracker.Name = "LevelTracker"
    local Level1 = Instance.new("BoolValue")
    Level1.Parent = LevelTracker
    Level1.Name = "Level1"
    Level1.Value = false
    local Value = TrackersData:GetAsync("Level1") -- Getting value from data store "TrackersData"
    if Value == nil then
       TrackersData:SetAsync("Level1",false) -- if value equals nothing then it'll creates it.
    else
       Level1.Value = Value
    end
end)

1 answer

✓ Accepted answer

First of all you should use Pcall when you are using datastores. Problem is that you are never saving the data. Only time you set data is if player doesn't have data in the datastore. You will have to save data before player leaves or at certain interval.

4 comments

1

You're supposed to add those changes and give him the general idea of where everything goes.

0

I suppose, not "supposed to". Maybe it's just a good way that's going around?

0

Oh boy I cant figure...

0

KDarren12 I think it's pointless to explain how to save data as that question has been answered multiple times. I was just pointing out the problem that he has got.

This discussion is preserved as it was. New answers, comments, and votes are closed.