My datasaving script is acting WEIRD

Alright so I was making a module for datasaving and well I’ll sum it up. It throws an error but the code still works. Here’s the code snippet:

while true do
		local success, errormessage = pcall(playerDataStore:SetAsync(plr.UserId, dataTable)) 
		if not success then 
			-- Datasaving was unsuccessful --
			print(errormessage)
			print("Error while saving "..plr.Name.."'s data, retrying in "..retryTime.." seconds.") 
			task.wait(retryTime)
			continue
		end
		-- Datasaving was successful --
		break
	end

When run:

However, I tested the game multiple times, and the datasaving still works. Anyone know what’s going on?

You’re not using pcall correctly. You need to pass it the function and it will call it for you.

pcall(playerDataStore.SetAsync, playerDataStore, plr.UserId, dataTable)

-- OR

pcall(function()
    playerDataStore:SetAsync(plr.UserId, dataTable)
end)