This script that I have made is supposed to filter through 7 values in the player's storage and determine which of them are true (one out of seven will always be true). However, when this script is activated, absolutely nothing happens; nothing is printed other than the first one, "loading." This really is frustrating me. Why won't it do anything?
game.Players.PlayerAdded:connect(function(player) print("loading") --The only thing that actually prints. wait(3) local DataStore = game:GetService("DataStoreService"):GetDataStore("lorStore") local text = player.PlayerGui.Tutorial.SaveNumber local key = "user-" ..player.UserId.. "-lastSlot" --The key. local savedValues = DataStore:GetAsync(key) if savedValues ~= nil then local values = {savedValues[1], savedValues[2], savedValues[3], savedValues[4], savedValues[5], savedValues[6], savedValues[7]} for i, v in pairs(values) do if v == true then print("loaded") text.Text = i --Whichever value is true, the number is put on the GUI. else print("nil") text.Text = "error" end end else print("key doesn't exist") end end)
Thank you for helping out! It means a lot!
all i did was change the data store but i tested both ways and it worked for me.
and the numbers in the datastore is a precaution in case so no can use the datastore as you
local DataStore = game:GetService("DataStoreService"):GetDataStore("lorStore34315262352352634426135") game.Players.PlayerAdded:connect(function(player) print("loading") --The only thing that actually prints. wait(3) local text = player.PlayerGui.Tutorial.SaveNumber local key = "user-" ..player.UserId.. "-lastSlot" --The key. local savedValues = DataStore:GetAsync(key) if savedValues ~= nil then local values = {savedValues[1], savedValues[2], savedValues[3], savedValues[4], savedValues[5], savedValues[6], savedValues[7]} for i, v in pairs(values) do if v == true then print("loaded") text.Text = i --Whichever value is true, the number is put on the GUI. else print("nil") text.Text = "error" end end else print("key doesn't exist") end end)