(仍然与 roblox 相关)倒计时停留在 15,并且玩家 2 在倒计时结束后加入时不会出现帧

(Still roblox related)Countdown stays at 15 and frame does not appear for player 2 when they join after the countdown ends

(是的,我知道这已经很老了,但我是脚本新手...)

所以我又遇到了这个问题,如果玩家 2 在倒计时结束后加入游戏,倒计时数字保持为 15,并且 MapVotingFrame 不会出现在玩家 2 上,但只会出现在玩家 1 上(就像我的第一个问题,但相反)这是第 3 次的脚本:

脚本:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("IntermissonEvent")

local secondsRemaining = 15

for t = secondsRemaining, 0, -1 do
    remoteEvent:FireAllClients(t)
    wait(1)
end

本地文字:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("IntermissonEvent")

local function onTimerUpdate(seconds)
       script.Parent.Text = tostring(seconds)

if seconds == 0 then
    script.Parent.Parent.MapVotingFrame.Visible = true
end
end

remoteEvent.OnClientEvent:Connect(onTimerUpdate)

尽量在你的问题中说得更清楚,我想我理解了问题,但你仍然应该包括更多的上下文

你的主要问题在

local secondsRemaining = 15

for t = secondsRemaining, 0, -1 do
   remoteEvent:FireAllClients(t)
   wait(1)
end

它保持在 15,因为您根本没有更改 secondsRemaining 的值。 在服务器脚本中将其更改为;

for t = secondsRemaining, 0, -1 do
   secondsRemaining = secondsRemaining - 1
   remoteEvent:FireAllClients(t)
   wait(1)
end