Help with DateTime lag

Hi everyone,

I am new to scripting and decided to play around with DateTime, I have tried to make this script that updates the text on a text label every second with the current time, but it seems to cuase major lag when attempting to play the game. However, when i run the code there is no lag and it works fine.

Can anybody explain to me why this is, I would much appreciate it!

while true do
	local DT = DateTime.now()
	game.Workspace.Screen.SurfaceGui.Frame.TextLabel.Text = DT:FormatLocalTime("LLLL", "en-us")
	task.wait(1)
end

This is the script, if you could explain to me what is wrong with it that would be super helpful with my development journey!

1 Like

This code shouldn’t cause lag. You may be dealing with malware

1 Like

Is this a Local script or just a script

1 Like

exactly may just be your computer

1 Like

Hey thanks for the reply!

I deleted the script and pasted the exact same code in it and it works fine now. I guess it was some sort of bug with Roblox studio? I’m not too sure, would you know?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.