The For Loop syntax is for init, max/min value, increment. Instead of creating a new variable and decrementing from it, you can simply do it inside the for loop.
local Map = "WaterRun";
local Time = script.Parent.Time;
local Pos = CFrame.new(-207.5, 15.5, 151.5);
local function Intermission()
for t = 30, 1, -1 do
Time.Text = t;
wait(1);
end
for _, plr in pairs(game.Players:GetPlayers()) do
if (Map == "WaterRun") then
plr.Character.HumanoidRootPart.CFrame = Pos;
end
end
end
script.Parent.StartRound.MouseButton1Click:Connect(Intermission);
Once you started adding in more maps, you will notice that conditional statements are very frustrating to use. To counter that, saving it in a table saves you great deal of time.
local Maps = {
["WaterMap"] = CFrame.new(100, 100, 100);
["AnotherMap"] = CFrame.new(200, 200, 200);
}
local Time = script.Parent.Time;
local function string_ChooseMap ()
local x = {};
for a , _ in pairs(Maps) do
table.insert(x, a);
end
local random = x[math.random(#x)];
return random;
end
local function void_Intermission ()
for i = 30, 1, -1 do
Time.Text = t;
print("Time " .. i);
wait(1);
end
local map = array_ChooseMap();
for _, plr in pairs(game.Players:GetPlayers()) do
plr.Character.HumanoidRootPart.CFrame = Maps[map];
end
end
script.Parent.StartRound.MouseButton1Click:Connect(void_Intermission);
8 comments
please fix your lua tags, enclose your code within those tildes
Please put your code inside the lua tags.
Please fix your qeustion, place the code inside the lua code block tags.
I answered your question, if it helps you, then please accept it as the correct answer
Also edit your title because it has nothing to do with what your question really is
So does it work? I'd like to know if you need anymore help
If my answer solves your problem, then mark it as the accepted answer
Should be a button the the upper right hand side of my answer that says something about accepting the answer