Hi, I have a round based game that teleports you once the intermission is over. I am very beginner at scripting, so I do not understand some of this. I want to make it so if everyone dies then the script goes back to intermission.
Here is the code I have right now:
local status = game.ReplicatedStorage:WaitForChild("Status") while true do status.Value = "Intermission (10)" wait(1) status.Value = "Intermission (9)" wait(1) status.Value = "Intermission (8)" wait(1) status.Value = "Intermission (7)" wait(1) status.Value = "Intermission (6)" wait(1) status.Value = "Intermission (5)" wait(1) status.Value = "Intermission (4)" wait(1) status.Value = "Intermission (3)" wait(1) status.Value = "Intermission (2)" wait(1) status.Value = "Intermission (1)" wait(1) target = CFrame.new(-131.76, 18.66, -120.07) --could be near a brick or in a new area for i, player in ipairs(game.Players:GetChildren()) do player.Character.Head.CFrame = target + Vector3.new(0, i * 5, 0) --add an offset of 5 for each character end function setTeam(player, teamName) player.TeamColor = game.Teams[teamName].TeamColor if player.Character then --Just in case the character doesn't exist for some reason end end for _, player in pairs(game.Players:GetPlayers()) do setTeam(player, "Playing") end status.Value = "Round in progress..." wait(200) status.Value = "Time is up!" wait(4) end
It would be greatly appreciated if you helped me. Thanks!
I recommend you to learn how to script firstly from wiki, which recently changed to robloxdev.com
. It is pretty clear your script is copy pasted. Also RIP grammar. Now let me give you a couple tips.
You do not have to fill a row with text and waits, you can just do this.
for i = 10, 1, -1 do status.Value = "Intermission..("..i..")" wait(1) end
Another tip is using functions, also putting the whole script in a while true do
loop will not fix anything.
EDIT: Some stuff from wiki is deprecated and do not learn from AlvinBlox.
To check if all players are dead, do this:
for _, player in next, game:GetService("Players"):GetPlayers() do if player.Character then if player.Character.Humanoid.Health == 0 then -- do code end end end