I am trying to create a code that teleports all players to the baseplate from the lobby once there are at least two players in the game. If anyone could help it would be much appreciated.
This isn't a request site.
I'll try to help you though (just create a script next time!)
So first you would need to count the players in the game.
You can easily do this by counting the children of players
1) Get the children
2) Get the amount of them
Like this
while wait() do local plrs = #game:GetService('Players'):GetChildren() end
The # is to get the amount of them
You test the am of players using if.
To teleport the player you simply change the HRP CFrame
Like this
while wait() do local plrs = #game:GetService('Players'):GetChildren() if plrs >= 2 then end end
To get all players use for i,v in pairs
Like this
while wait() do local plrs = #game:GetService('Players'):GetChildren() if plrs >= 2 then for index, plr in pairs(game.Players:GetPlayers()) do local char = plr.Character or plr.CharacterAdded:wait() -- Get the character of the player local HRP = char:WaitForChild('HumanoidRootPart') -- Wait For the HumanoidRootPart HRP.CFrame = CFrame.new(x,y,z) -- CHange the XYZ with the position or use script.Parent.CFrame for example end end end
Finally you want to add a debounce to not keep teleporting them
Debounce = true while wait() do local plrs = #game:GetService('Players'):GetChildren() if plrs >= 2 and Debounce then Debounce = false for index, plr in pairs(game.Players:GetPlayers()) do local char = plr.Character or plr.CharacterAdded:wait() -- Get the character of the player local HRP = char:WaitForChild('HumanoidRootPart') -- Wait For the HumanoidRootPart HRP.CFrame = CFrame.new(x,y,z) -- CHange the XYZ with the position or use script.Parent.CFrame for example end end end
You can run the script again by setting the Debounce to true again
If you have a question, just ask :)