Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Intermission Text stays as "Label" for some reason?

Asked by 4 years ago
Edited 4 years ago

Script 2:

local status = game.ReplicatedStorage.Status
local TimerDisplay = script.Parent.TimerDisplay

status.Changed:Connect(function()
    TimerDisplay.Text = status.Value
end)

Script 1:



local roundLength = 40 local intermissionLength = 40 local InRound = game.ReplicatedStorage.InRound local status = game.ReplicatedStorage.Status local GameAreaSpawn = game.Workspace.GameAreaSpawn local LobbySpawn = game.Workspace.Lobby local function roundTimer() while wait() do for i = intermissionLength, 1, -1 do InRound.Value = false wait(1) status.Value = "Intermission: ".. i .."seconds left!" end for i = roundLength, 1, -1 do InRound.Value = false wait(1) status.Value = "Intermission: ".. i .." seconds left!" end end end spawn(roundTimer)

I did everything correctly but still, the text says "Label" even though it's suppose to be numbers that count down. There are 2 separate scripts that is needed to work. How do I fix this?

0
Are you getting any errors in the output panel? Is the script that's supposed to be modifying the TextLabel a LocalScript? Is the other script a regular Script? Rinpix 639 — 4y
0
The textlabel has a local script and the other one with the local roundLength thingy is just a regular script Zisser_Z -2 — 4y
0
And no I don't get any errors Zisser_Z -2 — 4y

2 answers

Log in to vote
0
Answered by
p0vd 207 Moderation Voter
4 years ago
Edited 4 years ago

Here try this, accept if it works.

local roundLength = 40
local intermissionLength = 40
local InRound = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status

local GameAreaSpawn = game.Workspace.GameAreaSpawn
local LobbySpawn = game.Workspace.Lobby 


local function roundTimer()
    while true do
        for i = 1, intermissionLength do
            InRound.Value = false
            wait(1)
            status.Value = "Intermission: ".. i .."seconds left!"
        end
        for i = 1, roundLength do
            InRound.Value = false
            wait(1)
            status.Value = "Intermission: ".. i .." seconds left!"

        end
    end
end

spawn(roundTimer)
0
Didn't work sadly. Zisser_Z -2 — 4y
0
hmm ok p0vd 207 — 4y
0
Wait, the script disappears once I press play? Why does this happen? That might be the problem Zisser_Z -2 — 4y
0
well i just edited it try to fix that first p0vd 207 — 4y
View all comments (3 more)
0
It didn't work still. By the way, should I put the script in another place to see what happens? Since I have it in serverscriptservice and maybe I have to put it somewhere else to stop the problem from happening. Zisser_Z -2 — 4y
0
no its just because you're on the client and server can only see serverscriptservice so p0vd 207 — 4y
0
oh so what do i do then? Zisser_Z -2 — 4y
Ad
Log in to vote
0
Answered by
Rinpix 639 Moderation Voter
4 years ago

Ensure that the script you're modifying the TextLabel in is a LocalScript, and make sure you're using functions like :GetService() and :WaitForChild().

--Make sure this is a LocalScript.
local status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
local TimerDisplay = script.Parent.TimerDisplay

status.Changed:Connect(function()
    TimerDisplay.Text = status.Value
end)

It's possible that by the time the script reaches a line where you're assigning a variable to an instance that the instance has not yet loaded.

Do the same with the server script:

--Make sure this is a regular script, and preferably inside of ServerScriptService.
local roundLength = 40
local intermissionLength = 40
local InRound = game:GetService("ReplicatedStorage"):WaitForChild("InRound")
local status = game.ReplicatedStorage:WaitForChild("Status")

local GameAreaSpawn = game.Workspace:WaitForChild("GameAreaSpawn")
local LobbySpawn = game.Workspace:WaitForChild("Lobby")


local function roundTimer()
    while wait() do
        for i = intermissionLength, 1,  -1 do
            InRound.Value = false
            wait(1)
            status.Value = "Intermission: ".. i .."seconds left!"
        end
        for i = roundLength, 1, -1 do
            InRound.Value = false
            wait(1)
            status.Value = "There are ".. i .." seconds left in the game!"

        end
    end
end

spawn(roundTimer)

I also changed the second for loop in the roundTimer() function so that the text says that the game is currently in session.

If there are still any errors, or if anyone can spot one out that I made, please be sure to correct me.

0
There's no errors but it still doesn't work. Zisser_Z -2 — 4y
0
I will try a new script. Zisser_Z -2 — 4y

Answer this question