Hello.
-
What do you want to achieve? Create a system that spawns everyone in a map in the same place at the start. However, after dying in the map, you spawn in a completely random place on the map.
-
What is the issue? I don’t really know how to get it to script it, though I have some ideas on how to do it, and I’m genuinely quite lost on where to start. Another problem is that if the player dies, they get sent back to the spawn at the lobby.
-
What solutions have you tried so far? I think I know how to get it to work, I just need help putting it into practice. For communicaton purposes, assume that the part that all players teleport to at the start is called “Telepart”. The idea is:
- While a round is in progress (I have a boolean value in Replicated Storage that lets us know if it is in progress called “InRound”), first keep the telepart in a fixed position at the start for 2 seconds, and then move it to random positions at the same Y position, but with random X and Z coordinates.
- Check if player has died and is on the “Fighting” Team (= on the map)
- If the above condition is met, teleport the player (I assume this is using the CFrame) to the telepart at that moment and provide a forcefield for 2 seconds.
I’m quite new to game development on Roblox Studio specifically, and to the Developer Forum, so please let me know if I have done something really wrong. Here are 2 scripts in Server Script Service that relate to this:
-- Round Handler, decides if it is a round or not and shows intermission / round gui
local roundLength = 30
local intermissionLength = 5
local InRound = game.ReplicatedStorage:WaitForChild("InRound") -- bool value for if a round is in progress.
local Status = game.ReplicatedStorage:WaitForChild("Status") -- string value that holds what the GUI shows .
local LobbySpawn = game.Workspace.Lobby.LobbySpawn
local GameAreaSpawn = game.Workspace.Map.GameAreaSpawn
InRound.Changed:Connect(function()
wait(1)
if InRound.Value == true then
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame
end
else
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
end
end
end)
local function roundTimer()
while wait() do
for i = intermissionLength, 1, -1 do
InRound.Value = false
wait(1)
Status.Value = "Intermission: ".. i .." seconds left!"
end
for i = roundLength, 1, -1 do
InRound.Value = true
wait(1)
Status.Value = "Game: ".. i .." seconds left!"
end
end
end
spawn(roundTimer)
lua
-- Team Handler, puts people on a team.
local gamespawn = game.Workspace.Map.Floor
local lobbyspawn = game.Workspace.Lobby.Floor
local fighting = game.Teams.Fighting
local lobby = game.Teams.Lobby
gamespawn.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
plr.Team = fighting
end
end)
lobbyspawn.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
plr.Team = lobby
end
end)
Help would be greatly appreciated. Thank you so much!
P.S. I assume that you would need to know the minimum/maximum X and Z and the fixed Y position - you may refer to these as MaxX, FixedY for simplicity’s sake, or otherwise if you want.