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

Is Studio just getting mixed up?

Asked by 8 years ago

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
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. M39a9am3R 3210 — 8y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

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
Ad

Answer this question