Help on this code not running

Hello Devs,
I have this module script and a normal script and it doesn’t run.
Could you have any suggestions.

module script

local module = {}
function module.PartCount()
        local m = game.workspace.Model
        local pa = m:GetChildren()

        for i, pa in ipairs(pa) do
            print(i)
        end
end


return module

normal script

wait(16)
game.Players.PlayerAdded:Connect(function(plr)
    local WOWO = require(plr.AdministratorPanel.Scripts:WaitForChild("Modules").Home)
    WOWO.PartCount()
end)

Any feedback is appreciated!!

1 Like

By the time you connect the function to the PlayerAdded event, it has already fired. You can call the function on already joined players:

task.wait(16)

local function PlayerAdded(plr)
    --your code
end

for _, plr in ipairs(game.Players:GetChildren()) do
    PlayerAdded(plr)
end

game.Players.PlayerAdded:Connect(PlayerAdded)
1 Like

its actually a part counter.
what do i change so it becomes a part counter?
plus thanks for the feedback it is greatly appreciated!

print(#workspace.Model:GetChildren())
1 Like

You can use this module I made for you:
PartCount.rbxm (748 Bytes)
The module will return a number of parts
Here is a example of a normal script:

print(require(workspace.PartCount).PartCount(workspace.Model)) -- prints the returned number in the arguement
1 Like