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

i have this error Argument 1 missing or nil, how can i fix this?

i have this problem with my script it wont let me execute the ModuleScript that the serverscriptservice is executing but i keep getting an error here's my code:

local wow = script script=Instance.new'SelectionBox' local script = wow
local module = {}function module(player) 
    script.oofer_gang:Clone().Parent = game:GetService('Players'):FindFirstChild(player).PlayerGui
    _G.test = player
end
return module

can you help me plz?

Edit: New Problem's 'Requested module experienced an error while loading' or 'attempt to call a table value'

2 answers

✓ Accepted answer

Not sure what you're using a global variable for, but you can access variables 'globally' by requiring a module script. also, you forgot to put module infront of your function because what you're doing is creating a function inside of a table called module.

selectionBox = Instance.new'SelectionBox'
selectionBox.Parent = game.Workspace.Part -- parenting the selectionbox to a part in the workspace

local module = {}

module.myVar = "test variable"

function module.myFunction(player)
	script.oofer_gang:Clone().Parent = player.PlayerGui
	_G.test = player 
end
return module

you can access these functions by doing the following in a normal script:

--if your module is in the script service, reference like this vvv
myModule = require(game.ServerScriptService.myModule)


print(myModule.myVar)
myModule.myFunction(game.Players.royaltoe) -- calling the function with a player instance as it's parameter

I think your error might be something to do with the player not being passed in correctly or because our function isn't actually inside the modle script. This should change things and make it work.

10 comments

0

Hi, you've been online since I last posted, but you seem to not have the question answered. Do you still need this answer to be answered or does the code above work?

0

i dont have a module in the serverscriptservice i want it to be a script that can execute the require to players that join the game. plus do i need to change this part of the script where it says module.myVar = "test variable"

0

give me a second and i'll figure it out

0

I'm a bit confused about your question. Could you possibly explain what you're trying to do a bit more? If you're trying to call code from a ModuleScript in a normal script, you'd use the code in the answer I provided.

0

The ModuleScript can be put wherever you want it to be. A normal script can use require() to access the code in the module script like shown in the example. The part of the code where I said "module.myVar = "test variable"" I was giving an example of what a variable inside a modulescript would look like. You can delete it if you'd like, but it is just a way of using variables between scripts witho

0

without having to use _G like you did in your question

0

If you explain your problem a bit more I can help further.

0

basically im trying to make a script in the serverscriptservice that run's the code in the module and shows my gui thats in the module script but i keep getting the error so i tryed your code and it seemed to not show the Argument 1 missing or nil but its showing more errors, i keep trying to find out what the error is but its to confusing for me.

0

what are the errors

0

update your post with what you currently have

found the answer

local module = {}
script.oofer_gang:Clone().Parent = game.StarterGui
return module

quite simple idk y i didnt see it before but its fine now thanks for the help tho

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