No descriptive error?

Roblox Studio just pumps out an error and doesn’t seem to want to help me with anything. I can’t seem to figure out what is going on. This is a problem with one of my modules, which I was gonna release but stopped for a bit because of this, but imma leak the code, cuz I really don’t know what is going on here. If anyone can help me:

This seems to happen on module.RedeemCode()

Module
local ds = game:GetService("DataStoreService"):GetDataStore("CodesSystemModule")

local codes = require(script.CodesList)

local plrRedeemed = {}
local plrDebounces = {}

local module = {}

local function IsValidCode(input)
	for i, v in pairs(codes) do
		if string.lower(i) == string.lower(input) then
			if v.Expired == false then
				return true
			end
		end
	end
	return false
end

local function GetCodeReward(input)
	if IsValidCode(input) then
		for i, v in pairs(codes) do
			if string.lower(i) == string.lower(input) then
				return v.Reward
			end
		end
	end
end

local function IsAlreadyRedeemed(plr, input)
	local CheckRedeemedTable = function(plr, input)
		for i, v in pairs(plrRedeemed) do
			if i == plr.UserId.."-"..string.lower(input) and v == true then
				return true
			end
		end
		return false
	end
	local IsOnTable = CheckRedeemedTable(plr, input)
	if IsOnTable then
		return true
	end
	if plrRedeemed[plr.UserId.."-"..string.lower(input)] == false then
		return false
	end
	local RedeemValue
	local s, x = pcall(function()
		local getData = ds:GetAsync(plr.UserId.."-".. string.lower(input))
		if getData == true then
			plrRedeemed[plr.UserId.."-"..string.lower(input)] = true
			RedeemValue = true
		else
			plrRedeemed[plr.UserId.."-"..string.lower(input)] = false
			RedeemValue = false
		end
	end)
	if not s and x then warn(x) end
	return RedeemValue
end

module.canBeRedeemed = function(plr, input)
	if IsValidCode(input) then
		print(IsValidCode(input))
		if GetCodeReward(input) ~= nil then
			print(GetCodeReward(input))
			print(IsAlreadyRedeemed(plr, input))
			if IsAlreadyRedeemed(plr, input) == false then
				return true
			end
		end
	else
		return false
	end
end

local removePlayerFromDebounce = function(plr)
	plrDebounces[plr.UserId] = false
end

module.RedeemCode = function(plr, input)
	if typeof(plr) == "Instance" and plr:IsA("Player") and plrDebounces[plr.UserId] ~= true then
		plrDebounces[plr.UserId] = true
		if IsAlreadyRedeemed(plr, input) == false then
			plrRedeemed[plr.UserId.."-"..string.lower(input)] = true
			ds:SetAsync(plr.UserId.."-"..string.lower(input), true)
			delay(removePlayerFromDebounce(plr), .5)
			return {Redeemed = true, Reward = GetCodeReward(input), ErrorCode = "A1"}
		else
			delay(removePlayerFromDebounce(plr), .5)
			return {Redeemed = false, Reward = nil, ErrorCode = "A3"}
		end
	end
	if plrDebounces[plr.UserId] ~= true then
		delay(removePlayerFromDebounce(plr), .5)
		return {Redeemed = false, Reward = nil, ErrorCode = "A6"}
	end
end


--Remove player's cached info

game.Players.PlayerRemoving:Connect(function(plr)
	--print(plr, "has left, removing cached info from CodesModule;")
	for i, v in pairs(plrRedeemed) do
		local userId = tostring((plr.UserId))
		local userIdPart = string.sub(i, 1, #userId)
		if string.sub(i, #userId + 1, #userId + 1) == "-" then
			plrRedeemed[i] = nil
		end
		if plrDebounces[tostring(plr.UserId)] then
			plrDebounces[tostring(plr.UserId)] = nil
		end
	end
end)

return module

Error:

image

Almost forgot to post the error lol

This also only happends when the code is sucessfully redeemed.

2 Likes

Please try giving more information and debugging your code, It’s just way too much for us to see!

1 Like

I just did! I forgot about putting the error on the post LOL!

1 Like

I tried remaking the code that calls the function, same error, so it has to do with the module.

delay(removePlayerFromDebounce(plr), .5) 

Delay number comes first before function

2 Likes

Oops, thanks! I’ll try that! Just a sec…

Hm, that’s weird…

Try doing this instead:

delay(.5,function()
    removePlayerFromDebounce(plr)
end)
5 Likes

@LucasTutoriaisSaimo did this work?

Yes! It did! It’s annoying that roblox didn’t give me a specific error about it.

1 Like