So I tried creating a stamina module that sets a variable to true if a player has enough stamina however if I try to change this variable in a module script it won't return as true but as false how can I fix this?

Attack Script

local CanCast = false

StaminaModule.TakeAwayStamina(Player,Amount,CanCast)
	
	wait()
	warn(CanCast)
	--CooldownModule.CreateAbilityCooldown(Player,10,"CooldownAbilityOne")
	
	if CanCast then

Module

local staminamodule = {}
function staminamodule.TakeAwayStamina(Player,Amount,CanCast)
	local Atributes = Player.Atributes
	local Stamina = Atributes.Stamina
	if Stamina.Value >= Amount then
		Stamina.Value = Stamina.Value - Amount
		CanCast = true
		warn(CanCast)
	end
end


return staminamodule

1 comment

0

by saying "if CanCast", you are checking if it's nil or not, not false or true (I assume you know that but just checking) Also if these are 2 different scripts CanCast is for each script separately which you should know as well.