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

why won't the second script load the data?

Hello guys! I still can't figure out why won't the second datastore would load the BoolValue. It sends no errors back it just won't load up.

first datastore script (works):

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("CompleteSaveSystem")
local ds2 = datastore:GetDataStore("TTSaveSystem")

game.Players.PlayerAdded:connect(function(plr)
 local folder = Instance.new("Folder", plr)
 folder.Name = "leaderstats"
 local Complete = Instance.new("IntValue", folder)
 Complete.Name = "Completes"
 local TT = Instance.new("IntValue", folder)
 TT.Name = "Tree Tokens"

 Complete.Value = ds1:GetAsync(plr.UserId) or 0
 ds1:SetAsync(plr.UserId, Complete.Value)

 TT.Value = ds2:GetAsync(plr.UserId) or 0
 ds2:SetAsync(plr.UserId, TT.Value)

 Complete.Changed:connect(function()
  ds1:SetAsync(plr.UserId, Complete.Value)
 end)

 TT.Changed:connect(function()
  ds2:SetAsync(plr.UserId, TT.Value)
 end)
end)

second script (won't work):

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)

4 comments

0
0

When i mean I still can't figure I mean I did it some times

0

A good thing is to do some printing. Print what stuff the TrackersData gets from the datastore f.ex. Not checking thru the script yet because this is something you could check yourself. (:

0

how do I do that?

1 answer

Never put a number in a variable or object name. Roblox struggles when you do this. change the 1 to a One

1 comment

0

Thank you, but still it won't work

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