It seems like you want to be able to pass one variable, for instance the numeral 5 over to another script. This is where Remote Events WOULD have been extremely efficient and more useful, only if you wanted to use them. So, in one glance I can see a few errors in which could have possibly caused your error.
mod = {}
mod.passVariable = function(plr)
print(plr.ClassName)
return plr.ClassName
end
return mod
Now, the parentheses that you add at the end of 'end' was removed due to it not being needed, I also added a return after the print so we can use the function as a variable.
local p = game.Players.LocalPlayer
local a = require(workspace["Test Script"])
local var = a.passVariable(p)
In my changes for the upper segment I have adding in the parentheses that you possibly forgot to implement, I also changed your variable to local variables as your variables were previously global, which slows down performance and were inefficient. Next, having respect for my first correction I reminded myself that we return the value when the function is called, so I changed the area where we call the 'passVariable' function to a variable so we can use the return value later on. I also changed 'game.Workspace' to 'workspace' as it saves space and is more efficient. Cheers!
1 comment
What do you actually want? Why do you need to "pass a player type into another script"? Is it a Script or a LocalScript?