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

Trying to use a ScriptModule error: Attempt to call an Instance?

I have a module script inside ReplicatedStorage, when I try to require and use it as a function inside a script located in ServerScriptService I get an error saying Attempt to call an instance

My ServerScriptService file:

local GetRandomNums = RS.Utils:WaitForChild('GetRandomNums')
-- ...
 local randomNums = GetRandomNums(0, #players:GetPlayers(), 2) 


The Module itself:

function GetRandomNums(min, max, numsCount)
	-- ...
end
 
return GetRandomNums

How can I fix this problem?

1 answer

✓ Accepted answer

You need to require the module

local GetRandomNums = require(RS.Utils:WaitForChild('GetRandomNums'))
-- ...
 local randomNums = GetRandomNums(0, #players:GetPlayers(), 2) 

1 comment

0

OOOOOF, How was I that stupid? how I didn't realize this

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