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

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

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
2
Answered by
appxritixn 2235 Moderation Voter Community Moderator
2 years ago

You need to require the module

local GetRandomNums = require(RS.Utils:WaitForChild('GetRandomNums'))
-- ...
 local randomNums = GetRandomNums(0, #players:GetPlayers(), 2) 
0
OOOOOF, How was I that stupid? how I didn't realize this zeyadtota3 7 — 2y
Ad

Answer this question