【问题标题】:(Still roblox related)Countdown stays at 15 and frame does not appear for player 2 when they join after the countdown ends(仍然与 roblox 相关)倒计时停留在 15 并且玩家 2 在倒计时结束后加入时不会出现帧
【发布时间】:2020-12-18 18:09:35
【问题描述】:

(是的,我知道这已经很老了,但我对脚本很陌生...)

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

脚本:

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)

【问题讨论】:

    标签: roblox


    【解决方案1】:

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

    你的主要问题在于

    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
    

    【讨论】:

    • secondsRemaining 仅用于在 for 循环中初始化 t 变量。 tvariable 适当地递减到 0。
    猜你喜欢
    • 2020-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多