-
What do you want to achieve? Keep it simple and clear!
I am making a countdown timer. I want it to show the same time for all the players. -
What is the issue? Include screenshots / videos if possible!
The timer works perfectly, but if a player joins when the timer is going, the time for the 2 players will be different. For example, it is intermission and 5 seconds for the 1st player but it is 10 for the other player. - What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Here is my script (it is inside the textlabel)
--scripted by anirudh851
--this handles rounds
function round()
local target = workspace.GameSpawn.CFrame
for i, player in ipairs(game.Players:GetChildren()) do
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
local t = 5
while t > -1 do
wait(1)
local status = game.ReplicatedFirst.Status
status.Value = "Time left: " .. t
script.Parent.Text = status.Value
t = t - 1
if t == -1 then
wait(1)
intermission()
end
end
end
function intermission()
local target = game.Workspace.Lobby.LobbySpawn.CFrame
for i, player in ipairs(game.Players:GetChildren()) do
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
local it = 5
while it > -1 do
wait(1)
local status = game.ReplicatedFirst.Status
status.Value = "Intermission: " .. it
script.Parent.Text = status.Value
it = it - 1
if it == -1 then
wait(1)
round()
end
end
end
round()
Location of the script in explorer is StarterGui > Timer(ScreenGui) > TextLabel > Script
All replies are appreciated! Thank you!