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

How to get player with a module script?

Asked by 8 years ago

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.

0
And none of these have worked evildustin6677 0 — 8y
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 User#5423 17 — 8y
0
I have that.. evildustin6677 0 — 8y
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. BlackJPI 2658 — 8y
View all comments (3 more)
0
Its not firing at all. evildustin6677 0 — 8y
0
What are you actually trying to do? When is this loaded? What's this for? Info info info we need more. User#6546 35 — 8y
0
It has a UI inside the Module script, and I want the UI to be cloned and Put into the PlayerGui evildustin6677 0 — 8y

1 answer

Log in to vote
0
Answered by
Veyrek 5
8 years ago

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)

Ad

Answer this question