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

My change GUI Text script is not working and I can't find a solution?

Asked by 4 years ago
Edited 4 years ago

I'm trying to make it so the text on a GUI will change when it is a certain time of day in roblox. I have it set up so there is a StringValue in ReplicatedStorage named "StatusValue". Then I have a text label in a gui on Roblox named "TaskName" there is a script in TaskName that makes it so the Text reads whatever the value of StatusValue is. Finally there is a script in ServerScriptService which i have set to change the Value of StatusValue during certain times of day. But for some reason when i test it out the StatusValue does not change and so forth my GUI does not function as intended. Here is the ServerScriptService script I am using. I can't figure out whats wrong with it. Help will be much appreciated. Thank you!

local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")
local l = game.Lighting:GetMinutesAfterMidnight()

    if l<6 or l>6.5 then
        status.Value = "Wake Up Call"
    end

    if l<6.5 or l>7 then 
        status.Value = "Breakfast"
    end

    if l<7 or l>12 then 
        status.Value = "Free Time"
    end

    if l<12 or l>19.5 then 
        status.Value = "Hard Labor"
    end

    if l<19.5 or l>20 then
        status.Value = "Dinner"
    end

    if l<20 or l>23 then
        status.Value = "Free Time"
    end

    if l<23 or l>6 then
        status.Value = "Lights Out"
    end

Here is the LocalScript that is supposed to change the TextLabel to the value of the StatusValue

local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")

script.Parent.Text = status.Value
status.Changed:connect(function()
script.Parent.Text = status.Value   
end)
0
Please also post the LocalScript that reads StatusValue.Value P100D 590 — 4y
0
I added the LocalScript to the post niceboy1419 14 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Since l = the minutes after midnight, what you are checking for in the script is if its 6 minutes after midnight, not 6 hours, all you need to do is add a *60 to all of them

local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")
local l = game.Lighting:GetMinutesAfterMidnight()

    if l<6*60 or l>6.5*60 then
        status.Value = "Wake Up Call"
    end

    if l<6.5*60 or l>7*60 then 
        status.Value = "Breakfast"
    end

    if l<7*60 or l>12*60 then 
        status.Value = "Free Time"
    end

    if l<12*60 or l>19.5*60 then 
        status.Value = "Hard Labor"
    end

    if l<19.5*60 or l>20*60 then
        status.Value = "Dinner"
    end

    if l<20*60 or l>23*60 then
        status.Value = "Free Time"
    end

    if l<23*60 or l>6*60 then
        status.Value = "Lights Out"
    end
0
I added this to the script, and while this is probably one problem with my script I tested this in studio and in a published place and it didn't work in either niceboy1419 14 — 4y
Ad

Answer this question