Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I fix this variable returning false when it should be true?

Asked by
hokyboy 270 Moderation Voter
3 years ago

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

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. greatneil80 2647 — 3y

Answer this question