Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't my tool loading? And nothing is printing when i use GetAsync

code:

local DataStore = game:GetService("DataStoreService")
local SaveTools = DataStore:GetDataStore('Save_Tools')
----
game.Players.PlayerAdded:Connect(function(player)
	local tools = player:WaitForChild('Backpack')
	for i,v in pairs(tools:GetChildren()) do
	local data = v
	local success, errormessage = pcall(function()
		SaveTools:GetAsync(player.UserId..'-Tools')
	end)
	if success then
		print('Loading tools')
		local Curr_Tools = data:Clone()
		Curr_Tools.Parent = player.Backpack
	if not success then
		print('Oh no, A error occured!')
		warn(errormessage)
end
	end
	end
	end)

4 comments

0

This doesn't make sense. You're getting tools from the players backpack and upon a successful return of loaded data, you're re-parenting those same tool to their Backpack.

0

But why isn't it printing though?

0

When it succseded

0

You have not success in the success scope, so it's not going to print.

1 answer

	local DataStore = game:GetService("DataStoreService")
	local SaveTools = DataStore:GetDataStore('Save_Tools')
	----
	
	local errormessage = "An error has occured!"
	
	game.Players.PlayerAdded:Connect(function(player)
	    local tools = player:WaitForChild('Backpack')
	    for i,v in pairs(tools:GetChildren()) do
	    local data = v
	    local success, errormessage = pcall(function()
	        SaveTools:GetAsync(player.UserId..'-Tools')
	    end)
	    if success then
	        print('Loading tools')
	        local Curr_Tools = data:Clone()
	        Curr_Tools.Parent = player.Backpack
	    if not success then
	        print('Oh no, A error occured!')
	        warn(errormessage)
	end
	    end
	    end
	    end)

You forgot to put "Local errormessage = "An error has occurred!" "

Let me know if this works.

1 comment

0

Error message should be what went wrong in the pcall it shouldnt be a string.

This discussion is preserved as it was. New answers, comments, and votes are closed.