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

How do I make a text label's text change to the different days as time progresses?

local Days = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}

game.Players.PlayerAdded:connect(function() game.Lighting.Changed:connect(function(property) if property == "TimeOfDay" then for i,v in ipairs(Days) do local minutes = game.Lighting:GetMinutesAfterMidnight() if minutes == 0 then script.Parent.Text = "Day: "..v end end end end) end)

1 answer

✓ Accepted answer

You could try adding this in a local script inside the text label (assuming you already have a separate day/night script that doesn't skip any minutes):

local Days = --days table here
local DayCount = 1
game.Lighting.Changed:Connect(function(property)
	if property == "TimeOfDay" then
		local minutes = game.Lighting:GetMinutesAfterMidnight()
		if minutes == 0 then
			script.Parent.Text = "Day: " .. Days[DayCount]
			DayCount = DayCount + 1
			if DayCount > 7 then
				DayCount = 1
			end
		end
	end
end)

You also have to set the ResetOnSpawn property of the ScreenGui the label is in to false, so it does not reset the cycle when the player dies.

1 comment

0

Thanks. I noticed you didn't loop through the table.

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