Module script boolean not changing when it should be

I have a situation where I have a module that stores a boolean value named “Reinstated” that can be only set true after a certain method is called. Now, when I call this method, nothing happens to the Reinstated value and because of this, all the functions that rely on this value to be true fail. This has been biting me in the ankles for an hour now and I still can’t understand why this is happening, I even had a seperate script that would loop call the value and it states that the value is true but when I print it inside the failing functions the value comes back as “false”. Please help.

example of my situation →

local ModuleScript = {
    Reinstated = false
}

-- note: this function is called in an outside script before the "FutureFunction" is called.
function ModuleScript:Reinstate()
    self.Reinstated = true
end

function ModuleScript:FutureFunction()
    -- this prints "false" for some reason after the Reinstate method has already ran, why is that?
    print(self.Reinstated) 
end

return ModuleScript

both scripts are running locally. The module script is exclusively ran locally as well and is stored in ReplicatedFirst.

You did not call Require:Reinstate() before the loop

You also have syntax error here, you forgot “)” at the end

Are you checking the output for errors? You have to debug your code!

No, sorry for miscommunicating. The outside script section I put is completely irrelevant to the problem, I shouldn’t of even put it there to be honest.

I was just reinforcing my point on how a script from an outside source calling the “Reinstated” value detects the change I was trying to make initially while when the module script refers to itself, it still reads the value as if it were unchanged to begin with.

If it helps, the method is called from a “CharacterAdded” event taking place. Although it shouldn’t matter that much because it doesn’t take any arguments.

The point is, the loop isn’t relevant. It’s the fact that a method I call on the module that’s supposed to change the value of “Reinstate” to true is only detected as true by scripts that require the module, not by the module itself. In cases that the module refers to itself, it only sees the Reinstate value as unchanged (a.k.a false).

Are you sure you’re calling the methods in order?

It’s working perfectly fine.

You might have an concurrency problem going on.

Nevermind, it was studio being janky. Just restarted it and it worked. Have a good rest of your day, I’ll give you the solution cause you were nice enough to respond.

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