Making teleport Gui

Hey guys, i’m trying to make it so that when one player clicks the play button, both players are tp’d to a separate part, It’s confusing to explain so i’ll attach a video, i want them both to be teleported when either presses the play button and I want them to be tp’d do different parts inside the arena… any ideas how I could script this?
robloxapp-20220813-1117400.wmv (622.6 KB)

Assuming this is a two player game, you could iterate over the players and spawn them on a random part of the arena (while storing the one that has already had the player spawned in to prevent them from spawning in the same place and checking against), or if you want them to spawn on each of the sides of the arena then i would reccommend storing the locations in a dictionary assigned to 1 and 2, then teleporting the players based on, for example, the i variable in for i,_ in ipairs(yourCharacters do etc.
If this is a more than two player game, you would need to store the player characters that are actually touching it first, then teleport them accordingly while disabling the bricks that light up, then do the above but only with the two players (you can get the players from characters using Player:GetPlayerFromCharacter, however it is not neccessary and you can just store the two characters in a list or two variables).

1 Like

First, do what @LuaBaseScript said, then you can use Character:MoveTo(Position) or Character:SetPrimaryPartCFrame(CFrame) to teleport the Character. I personally prefer :SetPrimaryPartCFrame than :MoveTo since :MoveTo doesn’t always teleport correctly.

:MoveTo

:SetPrimaryPartCFrame

1 Like

Hi, thanks for the response, sorry I’m new to coding and are struggling to understand what you are saying I should do… and yes I’m trying to spawn then on opposite sides of the arena. How would I store the locations of the part I’m trying to teleport them to? Thanks :slight_smile:

example

local arenaPositions = {
[1] = Vector3.new(0,1,0),
[2] = Vector3.new(20,1,0)
};
2 Likes