Ok so from what I can tell here you are trying to click a GUI button and have the server move the player into a folder. Later you teleport all players into a game.
First of all, the button probably runs a local script. If you don’t have a local script for the button then that is the reason you don’t see the print.
Secondly, to make a local script communicate with the server you need a remote event or a remote function (here it is better to use a remote function). The problem that you have right now is that when you call a module from a local script, the module is also local. So you cannot move the player’s character into the desired folder (you can, but only the client will see it).
So let’s start easy:
First create a RemoteFunction object in game.ReplicatedStorage (call it “AddPlayerToLevel”). Then move the initial script into a local script (in the exact same location, just swap from normal script to local). Make the script this instead of what you had.
local AddPlayerToLevel = game.ReplicatedStorage:WaitForChild("AddPlayerToLevel")
function click()
print("clicked")
if AddPlayerToLevel:InvokeServer(1) then
print("Player Added")
else
print("Player not added")
end
end
script.Parent.Activated:Connect(click)
Now create another script in ServerScriptService:
local AddPlayerToLevel = game.ReplicatedStorage:WaitForChild("AddPlayerToLevel")
local joinmanager = require(game.ServerScriptService:WaitForChild("JoinManager"))
function onAddPlayerToLevel(player, level)
if level == 1 then
if #game.Workspace.Level1Folder:GetChildren() <= 5 then
print("can join")
joinmanager.AddPlayerToLevel1(player)
return true
else
return false
end
end
return false
end
AddPlayerToLevel.OnServerInvoke = onAddPlayerToLevel
Try this and let me know if it works. What we do here is use a remote function to tell the server we want a player added to level 1. The server will reply true/false to let the client know if it successfully added the player to the folder.
EDIT: I Noted another problem in your solution. You cannot have an infinite while in a module script. This causes the require to never finish.
You also need to modify the module:
local module = {}
function module.AddPlayerToLevel1(player)
if game.Players:FindFirstChild(player.Name) then
game.Players:FindFirstChild(player.Name).Character.Parent = game.Workspace.Level1Folder
print("joined")
end
end
return module
And create another script and put the while there:
local Players = game:GetService("Players")
local level1 = {}
while true do
wait(5)
table.clear(level1)
for i,v in ipairs(game.Workspace.Level1Folder:GetChildren()) do
table.insert(level1, Players:GetPlayerFromCharacter(v))
end
if #level1 >= 2 then
game:GetService("TeleportService"):TeleportPartyAsync(6108619940, level1)
end
wait(0)
end