So basically, When you click deploy you will spawn into a random team spawn location. If that didn't make sense ------ | | | 1.There are two teams and different spawn locations for each team. 2. When you click the deploy button i want it to spawn you to one of your team spawn locations. 3. And i want the script to randomly pick a spawn location.
HasPressedTeleport = false function TeleportPlayer() if HasPressedTeleport == false then Player.Character:MoveTo(SpawnLocation)-- How would i make the script spawn end -- you to your teams spawnlocation end -- and make it randomize it.....
NOTE: When a player spawns, they spawn in a black box, then a gui will appear from StarterGui
. Every black box has
The game's hierarchy:
local team1 = game.Teams.RedTeam local team2 = game.Teams.BlueTeam local spawns1 = game.Workspace.RedSpawns:GetChildren() -- gets a table of all the spawns local spawns2 = game.Workspace.BlueSpawns:GetChildren() function teleportPlayer(player,team) -- function for teleporting the player if player.Character then local char = player.Character -- the player's character if team == team1 then char.Torso.CFrame = spawns1[math.random(1,#spawns1)].Position + Vector3.new(0,7,0) -- teleports the player elseif team == team2 then char.Torso.CFrame = spawns2[math.random(1,#spawns2)].Position + Vector3.new(0,7,0) end end end function setUp(player) -- setup function if player.TeamColor == team1.TeamColor then teleportPlayer(player,team1) -- calls the teleporting function elseif player.TeamColor == team2.TeamColor then teleportPlayer(player,team2) end end game.Players.PlayerAdded:connect(function(p) -- when a player joins p.CharacterAdded:connect(function() -- when the player's character spawns local gui = p.PlayerGui:WaitForChild("SpawnGui") -- finds the gui if gui then gui.Frame.JoinButton.MouseButton1Down:connect(function() -- when joinbutton is clicked setUp(p) -- calls the setup function gui:remove() -- deletes the gui so the user can play end) end end) end)
It looks daunting because of it's size, but this is actually pretty simple. Hope I helped. Any questions, PM EmeraldSlash on ROBLOX (my main).