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

how can i make each player tp to one area?

Hello , recently i decided to create a game like lab experiment , each players are on a plates and have to survive to random event the problem is : i recently started in scripting , so how can i make every players tp to their own plates?

1 answer

You need to have the server assign the plate to a player.

I'd advise using an object value in the plate called Player. You can make one with a script using this code (I'd advise using a for i.v loop here):

local Val = Instance.new("ObjectValue")
Val.Name = "Player"
Val.Parent = Path to plate object

Once you have it made the quickest way to assign the players is a for i,v loop. It would also help if the plates are numbered at the start of each round. You can use a script much like this:

for i,v in pairs(Plates:GetChildren()) do
	v.Name == i
end

for i,v in pairs(game.Players:GetChildren()) do
	Plates[i].Player.Value = v
end

Once you have assigned the plate a player you will use yet another for i,v loop to teleport the players using their HumanoidRootParts. The code below shows how:

for _,v in pairs(Plates:GetChildren()) do
	if v.Player.Value ~= nil then
		v.Player.Value.Character.HumanoidRootPart.CFame = CFrame.new(v.Position + Vector3.new(0,5,0))
	end
end

Just remember this is example code and will need to be changed to fit your game properly

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