I suck at explaining stuff but i’ll try my best lol. Anyways I have a left and right button, and when you click left I want want it to go to September 2022, and right would go up a month if that makes sense I just have no idea how I would do it though, any help is welcomed!
MonthYear.Text = os.date("%B %Y")
--this line is not in the script though the text changes to 'October 2022' fyi
Edit:
Thought about doing something like this but that does not seem to be the best way to do it
LeftButton.MouseButton1Up:Connect(function()
if Date == "October" and Year == "2022" then
MonthYear.Text = "September 2022"
end
end)
For this particular case, you could probably get away with something like this. It may be easier to use os.date, but I don’t deal with that, so in the event that no one else responds, here is some code that could work:
local Months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
local CurrentMonth = 10 -- Ill have a look for a way to have this value automatically set
local CurrentYear = 2022 -- same with this one
local function updateText()
MonthYear.Text = Months[CurrentMonth].." "..tostring(CurrentYear)
end
leftButton.Activated:Connect(function()
CurrentMonth -= 1
if CurrentMonth == 0 then
CurrentYear -= 1
end
updateText()
end)
rightButton.Activated:Connect(function()
CurrentMonth += 1
if CurrentMonth == 13 then
CurrentYear += 1
end
updateText()
end)
1 Like