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

How to get player with a module script?

Recently, I have decided to attempt to make an anti-exploit as well as a chat moderation script that is called by a loader... I am having trouble on getting the player parameter. I have tried :

game.Players.PlayerAdded:connect(function(Player)

end)

as well as:

game:GetService("Players").PlayerAdded:connect(function(Player)

end)

If someone could help me that would be great. I am trying to get it on 1 script.. Not 2 thank you.

7 comments

0

And none of these have worked

0

A module script needs another script to be able to run e.g. require() if you are trying to do this in a module script then it will not run until another script uses the require method

0

I have that..

0

Is the event not firing, or is the player parameter nil? It is likely that the event is getting connected after the player is added if it is not firing at all.

0

Its not firing at all.

0

What are you actually trying to do? When is this loaded? What's this for? Info info info we need more.

0

It has a UI inside the Module script, and I want the UI to be cloned and Put into the PlayerGui

1 answer

test purposes

-- for the module

local Test = {}

function Test:doFunction(player)
	print(player.Name.." has joined!")
end

return Test
-- for the script

local TestModule = require(workspace.Test)

game:GetService("Players").PlayerAdded:connect(function(Player)
	TestModule:doFunction(Player)
end)

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