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

How do we lock a place after a player joined so nobody else can join?

Hi guys! So, I want to make a Camping game and I've already done the lobby and the teleportation, but I'm afraid that when a group of players has been teleported to the In-game story they join different servers and that some of them will join already running In-game servers.

Also, the In-game story server is a place in the game that the player can just see the lobby server's Icon in their home page, and not the In-game story server's Icon

So my question is that after that group of players in a car has been teleported, how do we let them join in the SAME In-game server?

Help will be REALLY REALLY appreciated!!!!

1 answer

You can make a PlayerAdded event, and add a number to a variable, and if the variable has reached a certain amount, you can begin kicking players.

For example:

local playersRecorded = 0

game.Players.PlayerAdded:Connect(function(player)
	if playersRecorded == 5 then -- assume 5 players have joined
		player:Kick("Server-locked") -- kicks the player
	else
		playersRecorded = playersRecorded + 1 -- adds in a one to the recorded player amount
	end
end)

Or you can make one that automatically kicks players after a certain time period:

wait(3) -- assume players will have loaded by then, by waiting 3 seconds after server start up

game.Players.PlayerAdded:Connect(function(player)
	player:Kick("Server-locked")
end)

1 comment

0

But it's a camping game, and if we kick the player he has to rejoin the lobby and wait again

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