How do I make This TextLabel Display the Current Event based on the ClockTime in game?
Asked by
2 years ago Edited 2 years ago
In my game is a UI in the right top corner of the screen that displays the current time (7:00 AM, 10:30 AM) and below it is the current activity going on at school (Classtime, Lunchtime) I looked around to find some scripts that could help and I found this one script but I don't know certain terminology and details so I don't know exactly what to do with the script. I don't know whether it should be a LocalScript or not or any of that.
The UI is a ScreenGui and inside of it are Two Text Labels, one named CurrentTime, and the other named CurrentActivity. Inside of CurrentActivity is where this script is located which is why in the script I put "script.Parent.Text = Str" because I want the Text of the Parent (The CurrentActivity TextLabel) to display the text. But it also says to assign "Str" to something and I don't know what.
Anyways, here's the script, if anyone knows what to do, please let me know!
02 | [ "6.50" ] = "Before School" , |
03 | [ "7" ] = "Before Class" , |
04 | [ "8.50" ] = "Classtime" , |
06 | [ "13.50" ] = "Classtime" , |
07 | [ "15.50" ] = "After School" , |
14 | local IntTime = Instance.new( "IntValue" , script) |
15 | IntTime.Changed:Connect( function () |
16 | local Str = Schedule [ tostring (game.Lighting.ClockTime) ] |
20 | script.Parent.Text = Str |
24 | game.Lighting:GetPropertyChangedSignal( "ClockTime" ):Connect( function () |
26 | IntTime.Value = math.floor(game.Lighting.ClockTime) |
Edit: Okay, so the script does work, sort of. The reason it wasn't changing was because I was play testing in Roblox Studio and for some reason it wasn't changing in Roblox Studio but it was when I actually played the game through the Roblox website.
But the problem is, when it says 6.5, that's supposed to be the ClockTime for 6:30, but the Text doesn't change at 6:30, it will only change at 7 to Before Class. I tried changing 6.5 to just 6, but that didn't work either. I also went all the way to 8:30 AM, but it didn't change to Classtime like it was supposed to either. I'm having a difficult time trying to troubleshoot this so if anyone can help, please let me know