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!

6 comments
the datastore should be on line 1 before anything else.. just tested it and it prints "key doesnt exist" in my script test server. with datastore before the function and after so idk why it doesnt work for you
Thanks; I updated it, but the script still isn't working.
hmm thats weird. it works for me in studio and regular server. is there any output?
The only output is that it prints ("loading")
hmm that is weird. https://i.gyazo.com/22ff277b93a83bdc5d4aa9aa0558f7c5.png
I honestly can't debug unless you can give me a link to a screenshot of the Dev gui(F9) Because I can't see any errors.