hey, does anyone know why my script isnt working? this is from an alvinblox tutorial and is supposed to save and load a couch that you buy, but it doesnt even load the value. thanks!
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("DS")
local val = game.StarterGui.ComputerGui.ScrollingFrame.Couch:WaitForChild("Bought").Value
--load
game.Players.PlayerAdded:Connect(function(player)
local data
local success, errormessage = pcall(function()
data = DS:GetAsync(player.UserId.."CouchBought")
end)
if success then
print("Player data successfully loaded!")
print(DS:GetAsync(player.UserId.."CouchBought"))
val = data
else
print("There was an error while loading data.")
warn(errormessage)
end
end)
--save
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
DS:SetAsync(player.UserId.."CouchBought",val)
end)
if success then
print("Player data successfully saved!")
else
print("There was an error while saving data.")
warn(errormessage)
end
end)
--load models
game.Players.PlayerAdded:Connect(function(player)
wait(0.1)
if game.StarterGui.ComputerGui.ScrollingFrame.Couch.Bought.Value == true then
local item = game.ReplicatedStorage.Purchasables.Couch:Clone()
item.Parent = workspace
end
end)

2 comments
Are you testing it in studio? If so do you have 'Allow studio to access API services' enabled in settings > security? If not, the script wont work. Is there any errors its giving?
It might have something to do with the fact that there are two playeradded functions. Try moving the bottom one to a separate script.