Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is Studio just getting mixed up?

I'm using ModuleScripts for the first time in... about a year? Anyway, I remember most of my experiences with them and so far it's going well. But I ran into a bit of a problem as you can see with this GIF. See the blue lines underneath the code? I looked at it and it says "Unknown Global 'TweenJointC1'"

But clearly, above that, you can see "module.TweenJointC1"

Do I just need to put in module.TweenJointC1 instead of just TweenJointC1

1 comment

1

Yes. What the script is recognizing TweenJointC1 is it is part of the table module. Much like _G. you would have to put the module. at the beginning of the variable.

1 answer

✓ Accepted answer

When you define the TweenJointC1 variable, it is an index in the module table. It is not a direct member of the global environment; so, trying to reference it from the global environment is going to give you the error you received.

You need to access the value directly through the 'module' table.

module.Fire = function()
	module.TweenJointC1(weld3);
end

But like always, you can use variables to shorten repetitive lines of code.

local tc1 = module.TweenJointC1;

module.Fire = function()
	tc1(weld3);
end

This discussion is preserved as it was. New answers, comments, and votes are closed.