I’m creating a game similar to Breaking Point and I’m struggling to come up with ideas on how I could make a round system. It would need to be able to teleport players onto different seats and it would need to give players unique roles in which each role has a certain thing they can do. Any tips or ideas on how I could do this?
local Players = game:GetService('Players')
local Workspace = game:GetService('Workspace')
local Seats, Roles = {
Workspace['Seat1'].Position,
Workspace['Seat2'].Position,
}, {
'Role1';
'Role2'
}
--Could use loop to add seats if you don't want to manually
--for __, Seat : Seat in pairs(Workspace:WaitForChild('Seats'):GetChildren()) do
-- if Seat:IsA('Seat') then
-- table.insert(Seats, Seat.Position)
-- end
--end
task.spawn(function()
while true do
local Indexing = 1
for __, Player in pairs(Players:GetPlayers()) do
local PlayerCharacter = Player.Character or Player.CharacterAdded:Wait()
if PlayerCharacter and Seats[Indexing] then
PlayerCharacter:MoveTo(Seats[Indexing]) --Teleporting them to a seat
Indexing += 1
else
warn('Not enough seats for the players')
end
Player.Team = Roles[math.random(1, #Roles)]
end
--Add the rest of your code here
end
end)
just the base code
Well Spiffy, that is called an experience on Roblox.
What you are probably searching for is the process called “Game Loop”. This brings your game to life and let’s a server run infinitely as it loops through the game process.
If you want to learn to script Game loops, Roblox has a series of a tutorial for creating a battle royal game and one chapter is scripting the game loop.
You can try to use Danis code but beware that you should script it so you understand everything. When doing this, you can then later apply updates to the game loop and generally copy pasting a game loop if you never scripted one is more likely a temporary fix.
Learn scripting one and you have further advanced to coding a fully finished game.
I get the following error:
Script timeout: exhausted allowed execution time
I figured it out, switched while true do to while wait() do.