Script Erroring During Return

So basically my script keeps running an error, everything else works fine in the script but whenever I get the boolean from calling the script like this;

if Cooldowns_Module:CheckForCooldown(Player, "Telekinetic Push", true) then		
	return		
end

It keeps returning this error;

This is the script (the code is inside of a ModuleScript);

function CM:CheckForCooldown(Player, Ability_Name)
	
	if Utilities_Module:Check("Object", "Ability Cooldowns", Player, true) then

		task.spawn(function()

			local Success, Error = pcall(function()

				if Utilities_Module:Check("Object", Ability_Name, Player["Ability Cooldowns"], true) then

					return true

				elseif Utilities_Module:Check("Object", Ability_Name, Player["Ability Cooldowns"], false) then

					return false

				end

			end)

			if Error then

				warn('Error: '..Error)

				return

			end

		end)

	elseif Utilities_Module:Check("Object", "Ability Cooldowns", Player, false) then

		warn('Object: Ability Cooldowns was not found.')

		return

	end
	
end

Line 44 is the warn('Error: '…Error) part.

And it’s erroring during the return true/false statements for some reason and I’m not sure why but I need to figure out the issue so I can solve it, any tips?

Try changing it to a comma. Like so:

warn("Error: ", Error)

I think Error is probably a true or false value (a bool).

1 Like

Does this error message appear right away when the game starts, or does it appear when the function CM:CheckForCooldown is ran?

I have an ability system in place and when the function runs for that ability it doesn’t appear at first but then a cooldown is added and it checks for the cooldown afterwards when it it attempted to be used again, but since it never returns true/false it executes the ability anyway and I need to fix it.

I’ll try that now and see if it works.

So this is what it displays when I did that;

image

It still doesn’t return anything.

Okay so, It was the pcall function that was messing with the code so once I took that out the issue was fixed.

Thanks @mc7oof and @PirateBeary for helping, I appreciate it!