I had a previous post before linked to this... My datastore won't work, it only gets as far as line 25, and when i leave i get a 23:54:42.033 - Players:getUserThumbnailAsync() could not get DataModel on http response error pls help heres the script:

local datastoresev = game:GetService("DataStoreService")
local AbilityStore1 = datastoresev:GetDataStore("AbilityStore1")

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local Ability = Instance.new("StringValue")
    Ability.Name = "Ability"
    Ability.Parent = leaderstats


    
    AbilityStore1:GetAsync(player.UserId)
    -- Load--
    local success, errormessage = pcall(function()
		         data = AbilityStore1:GetAsync(player.UserId)
		print("Loading Data")
    end)

    if success then
		Ability.Value = data[1]
		print("Data Loaded Successfully")
    end
end)
game.Players.PlayerRemoving:Connect(function(player)
    local data = {player.leaderstats.Ability.Value}
    local success, errormessage = pcall(function()
		    AbilityStore1:SetAsync(player.UserId, data)
		
		

    end)

    if success then
        print("Data Successfully Saved") 
    else
        print("There was an error when saving player's ability")
        warn(errormessage)
    end

end)
	game:BindToClose(function()
			 local runserv = game:GetService("RunService")
			if runserv:IsStudio() then
				return
			end
			    local players = game.Players:GetPlayers()
    for _, player in pairs(players) do
        local userId = player.UserId
        local data = player.UserId
        if data then
            local success, result = pcall(function()
		    AbilityStore1:SetAsync(userId, data)
				print("Saved to user id")
            end)
            if not success then
                warn(result)
            end    
        end
    end
 
    print("completed saving player data")
		end)

3 comments

0

please format it properly! I can't understand!

0

I noticed that you load the player's "ability" two times, what's the purpose of that? Also "Players:getUserThumbnailAsync()" has nothing to do with this script.

0

For Bind To Clos