Hw to make a Horrific Housing distribution system?

Hey guys! I am making a game kind of like Horrific Housing and Lab Experiment and I am stuck on the player distribution system. What I mean by “Player Distribution” is like when the players are sent to their plates. I don’t need to create the plates as I am just going to have set ones there. So if anyone knows how to distribute players on to 9 different plates it would really help if you could explain how this could be done. I have searched the internet but I have not found anything helpful. Thank You! :+1:

Just loop over the all the current players and tp them to a respective plate by using the index of iteration

I have no clue what that means…

local plates = workspace.Plates:GetChildren()
local players = game.Players:GetPlayers()

for index, plate in plates do
    local player = players[index]

    if not player then break end

    player.Character:PivotTo(CFrame.new(plate.Position))
end

Replace the plates variable to the path to your folder which has all the plates (assuming they are baseparts). Also keep in mind that if the no. of players is greater than the no. of plates then the loop will break and not tp the remaining players.

ok I will try this! Thanks for helping

Didn’t work and there was no error. Any ideas?

Code?

My code is the same thing as what you sent

That is pseudo code and is to be modified such that it fits your game architecture. Could you send me the plates folder ss in explorer? Also, where are you running the script from? Also lastly, if this is a server script, the code might run before any player joins

Question 1: The folder is called “Plates” and it is in the workspace
Question 2: I am running this script from server script service
Question 3: It is a server script but I have tried to add a wait and it was still the same outcome.

There may be race conditions with this approach, try doing Players.PlayerAdded:Wait at the top instead.

Are all of its children baseparts?

1: I don’t know if that will affect the code but would that make something happen when a player is added?
2: Yes, they are all just resized parts.

wait for the folder, it has not loaded in yet
local plates = workspace:WaitForChild("Plates"):GetChildren()

Interesting. I will try that now

It’s for testing purposes only, in a real game you would probably call this code snippet when you want to spawn in the players (probably in a round loop)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.