In my game each round there is a random obby map, and there are some “checkpoints” (they are not really checkpoints) that give a tag to the players, when touched.
Also, I just want my players to have one tag at a time, so I scripted that too.
Here is the script for checkpoint0:
local cs = game:GetService(“CollectionService”)
script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild(“Humanoid”) and not cs:HasTag(part.Parent, “0”) and not cs:HasTag(part.Parent, “1”) and not cs:HasTag(part.Parent, “2”) and not cs:HasTag(part.Parent, “3”) and not cs:HasTag(part.Parent, “4”) and not cs:HasTag(part.Parent, “5”) and not cs:HasTag(part.Parent, “6”) and not cs:HasTag(part.Parent, “7”)then
cs:AddTag(part.Parent, “0”)
end
if cs:HasTag(part.Parent, “0”) then
print (“0”)
end
end)
Here is the script for checkpoint4:
local cs = game:GetService(“CollectionService”)
script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild(“Humanoid”) and not cs:HasTag(part.Parent, “4”) and not cs:HasTag(part.Parent, “5”) and not cs:HasTag(part.Parent, “6”) and not cs:HasTag(part.Parent, “7”)then
cs:RemoveTag(part.Parent, “3”)
cs:AddTag(part.Parent, “4”)
end
if cs:HasTag(part.Parent, “4”) then
print (“4”)
end
end)
You get the idea…
And also, here is my main script (that is going to be changed):
ServerStorage = game:GetService(“ServerStorage”)
ReplicatedStorage = game:GetService(“ReplicatedStorage”)
Players = game:GetService(“Players”)
local Team = game:GetService(“Teams”)
local Contestants = game.Teams.Contestants
local Spectators = game.Teams.Spectators
local Completed = game.Teams.Completed
local cs = game:GetService(“CollectionService”)
Maps = ServerStorage:WaitForChild(‘Maps’):GetChildren()
Status = ReplicatedStorage:WaitForChild(‘Status’)
while true do
--Intermission
local Countdown = 10 -- ten second intermission, make this as long as you want
repeat wait(1)
Countdown = Countdown - 1
Status.Value = 'Intermission : '..Countdown
until Countdown <= 0
--Choose the map.
Status.Value = 'Choosing Map...'
local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
local Spawns = ChosenMap:FindFirstChild('Spawns'):GetChildren()
local RandomSpawn = Spawns[math.random(1, #Spawns)]
local LobbySpawns = game.Workspace.Lobby:FindFirstChild('LobbySpawns'):GetChildren()
local RandomLobbySpawn = LobbySpawns[math.random(1, #LobbySpawns)]
wait(5) -- little pause, make this as long as you want
ChosenMap.Parent = workspace
Status.Value = 'Next Map Is: '
wait(2) -- little pause, make this as long as you want
Status.Value = ChosenMap.Name
wait(2) -- little pause, make this as long as you want
--teleport the players
for _, Player in pairs(Players:GetChildren())do
if Player.Character and Player.Character:FindFirstChild('Humanoid') then
Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
end
end
for _, Player in pairs(Players:GetChildren())do
Player.Team = Contestants
end
-- Reassign countdown based on chosen map's Duration value
Countdown = ChosenMap:FindFirstChild("Duration").Value
repeat wait(1)
Countdown = Countdown - 1
local minutes = math.floor(Countdown / 60)
local seconds = math.floor(Countdown % 60)
Status.Value = string.format("Time left : %.2d:%.2d", minutes, seconds)
until Countdown <= 0
--Teleport back to lobby
for _, Player in pairs(Players:GetChildren())do
if Player.Character and Player.Character:FindFirstChild('Humanoid') and Player.Team == Contestants then
Player.Character.HumanoidRootPart.CFrame = RandomLobbySpawn.CFrame
end
end
for _, Player in pairs(Players:GetChildren())do
Player.Team = Completed
end
for _, Player in pairs(Players:GetChildren())do
if cs:HasTag(Player.Character, "0") then
Player.Team = Spectators
end
end
Status.Value = 'The eliminated player is: '
for _, char in pairs(cs:GetTagged("0")) do -- This removes all tags, for new map
cs:RemoveTag(char, "0")
end
for _, char in pairs(cs:GetTagged("1")) do -- This removes all tags, for new map
cs:RemoveTag(char, "1")
end
for _, char in pairs(cs:GetTagged("2")) do -- This removes all tags, for new map
cs:RemoveTag(char, "2")
end
for _, char in pairs(cs:GetTagged("3")) do -- This removes all tags, for new map
cs:RemoveTag(char, "3")
end
for _, char in pairs(cs:GetTagged("4")) do -- This removes all tags, for new map
cs:RemoveTag(char, "4")
end
for _, char in pairs(cs:GetTagged("5")) do -- This removes all tags, for new map
cs:RemoveTag(char, "5")
end
for _, char in pairs(cs:GetTagged("6")) do -- This removes all tags, for new map
cs:RemoveTag(char, "6")
end
for _, char in pairs(cs:GetTagged("7")) do -- This removes all tags, for new map
cs:RemoveTag(char, "7")
end
ChosenMap:Destroy()
end