i am making several loading screens and i want the game to use data stores to remember what one the player selected
if it can't find the data then it should display an error
but i get error attempt to index nil with what_failed
the script is in game > workspace > data_store_folder > DSS_script
what failed is in player's character
DSS_script:
local DSS = game:GetService("DataStoreService")
function new_player(player)
--getting the load screen number
local player_gui = player.PlayerGui
local loading_type_store = game:GetService("DataStoreService"):GetDataStore("loading_type")
local player_id = player.UserId
local character = player.Character
local wf_copy = character.what_failed:Clone()
local loading_type_value = character.load_screen_selected
local loading_type
local success, err = pcall(function()
loading_type = loading_type_store:GetAsync(player_id)
end)
if success then
loading_type_value.Value = loading_type
character.load_screen_selected.Parent = character.load_screen
character.loading_screen.Parent = player_gui
else
warn("could not retrieve data")
character.what_failed.Value = "getting load screen number"
wf_copy.Parent = player_gui
end
end
game.Players.PlayerAdded:Connect(new_player)

3 comments
what line is it at?
fixed it just needed to add a wait(1) to the start of the fuction
jeremqpmfpi