Datastore local variable error

i have two weird errors (more info below)

	local success, errormessage pcall(function()
		
		data = cb_ds:GetAsync(user_id)
		
	end)
	
	if success and data then 
		cb.Value = data
	else
		warn(player.Name .. " has no data")
		print(data)
	end
		local success, errormessage pcall(function()
			save_bux(player)
		end)
		
		if success then
			print("data has been saved")
		else
			warn("data has not been saved")
		end
		

there is a error on both of the “if success” and i dont understand why it isnt working, it works for stuff like this

	local success, errormessage = pcall(function()
		cb_ds:SetAsync(user_id, cb.Value)
	end)

	if success then
		print("saved bux")
	else

		print("error on saving bux")
		warn(errormessage)

but not any of those other two

  1. What is the error that you are getting?
  2. is save_bux a function? (im guessing it is but I just want to make sure)

yes save_bux is a function, and the error im getting is that it doesnt register as a variable even though it autofills it for me

I think it might be because you forgot to put an equal sign between errormessage and pcall

local success, errormessage = pcall(function()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.