Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

(Repost) Trying to set text in a TextLabel to certain text depending on the clocktime isn't working?

This is a repost because my last post got buried and wasn't ever answered.

So basically as the title says, I'm making something similar to what Prison Life does with the "Yard Time" & "Dinner". My script isn't working and I have been trying to figure out why but I can't seem to find out.

Script:

local text = script.Parent.Text
local clocktime = game.Lighting.ClockTime

while wait() do
    if clocktime == 6 then
        script.Parent.Text = "Breakfast"
    elseif clocktime == 8 then
        script.Parent.Text = "Free Time"
    end

    if clocktime == 12 then
        script.Parent.Text = "Lunch"
    elseif clocktime == 14 then
        script.Parent.Text = "Yard Time"
    end

    if clocktime == 17 then
        script.Parent.Text = "Dinner Time"
    elseif clocktime == 18 then
        script.Parent.Text = "Free Time"
    end

    if clocktime == 22 then
        script.Parent.Text = "Lights Out"
    end
end

(p.s., This script uses clocktime because I have a day/night cycle I made that also uses clocktime. Although you can change between TimeOfDay and Clocktime, I prefer ClockTime.)

1 comment

0

did my answer work

1 answer

✓ Accepted answer

First, make a NumberValue and put it in StarterGui. Name it “clock”.

Put this script in the text label



while wait(60) do
game.StarterGui.clock.Value = game.StarterGui.clock.Value + 1
end
local text = script.Parent.Text
local clocktime = game.StarterGui.clock

while wait() do
    if clocktime.Value == 6 then
        script.Parent.Text = "Breakfast"
    elseif clocktime.Value == 8 then
        script.Parent.Text = "Free Time"
    end

    if clocktime.Value == 12 then
        script.Parent.Text = "Lunch"
    elseif clocktime.Value == 14 then
        script.Parent.Text = "Yard Time"
    end

    if clocktime.Value == 17 then
        script.Parent.Text = "Dinner Time"
    elseif clocktime.Value == 18 then
        script.Parent.Text = "Free Time"
    
end
    if clocktime.Value == 22 then
        script.Parent.Text = "Lights Out"
end
    end
end

2 comments

0

I will try this!

0

Alright, any output and inform me

This discussion is preserved as it was. New answers, comments, and votes are closed.