[SEIZURE WARNING] Why does my program flicker?

SunSpin.rbxl (60.8 KB)

try doing “print(d)”, the y for some reason flips…

Thanks!

1 Like

Most likely due to you updating the TimeOfDay for every frame. Instead I would use tweenService to smooth the transition.

“Warning: The script ‘Script’ with a non-legacy RunContext is parented to a container ‘StarterGui’, which will cause it to run multiple times. To avoid unintended behavior, consider setting the RunContext to ‘Legacy’, disabling the script, or moving it to a different location.”

few problems here … you have server script in a gui and it’s runcontext is set to client.

SunSpin.rbxl (62.0 KB)
Here, I updated it, and the issue still persists…

Wouldn’t it then just flicker back and forth, but smoother and slower? I need it to be always day. Thanks! :D

I’ve looked at this more than a few times and still don’t see what you’re looking to do here.
If you print out the ToTimeOfDay(rad_sc(lon)*24 - 6) this is what you get … and that is what you’re seeing.

0
-12
0
-12
0
-12

I’m looking to do this: How to make the sun move with the camera, with a few caveats?

Yes, and I assume this is what’s causing the flicker. Why does it change back and forth? Can I make it constantly one number, either 0 or -12? Thanks!

Why -12?
Time of day from what I remember is 0 to 24.

I haven’t looked, but what is the variable that controls what time of day is selected?
Set it to 0 for one change, but only set it to 12 when that variable changes again.

check for when x changes
if x = true (or whatever the parameter is) then
time of day should be 12
else
time of day should be 0

but don’t flip it back and forth every time.

that’s unfortunately just a band aid over a symptom. I think it’d be wiser to get the root cause :hugs:

Because you’re telling it to with;
game.Lighting.GeographicLatitude =
game.Lighting.TimeOfDay =

By your math this is setting the time and latitude. 0 is always going to be dark.
That’s midnight to dawn.

Yes, 0 is always going to be dark. I agree.

However, why is it 0? Is there an error in my math, if so, where?

Thanks!

Well if you look at your other script it’s between 24 and 12. That program also contains some serious re-wrights… PlayerModule, PlayerScriptsLoader, RbxCharacterSounds. With even more intense Modules, metatables and all. Are you missing scripts from that? The new program has none of them.
Possibly use that math … seems to work fine.

Are you trying to pull that part of that program out for the new program?
If so that is a web of metatables … gl

Oh… I figured out why :pensive:

it keeps adding on to the variable, it keeps flipping the x&y :sob:

This:
image
Is the same as:
image

image

yeah… im a dum dum

My other script? You mean the one in replicated storage?

I’m not sure what you mean, may you provide a screenshot?

Are we looking at the same thing? :sweat_smile:

From your link they are in StarterPlayer.StarterPlayerScripts – must be some mod addon.
nvm that whole thing is comming from StarterGui with

local RunService = game:GetService("RunService")
local Lighting = game:GetService("Lighting")

local camera = workspace.CurrentCamera

local atan2 = math.atan2
local sqrt = math.sqrt
local tau = math.pi * 2

RunService.RenderStepped:Connect(function()

	local dir = -camera.CFrame.LookVector

	local lf = -1 -- Sun is "-1", Moon is "1"
	local lat = atan2(dir.Z, sqrt(dir.X^2 + dir.Y^2))
	local lon = atan2(dir.Y * lf, dir.X * lf)

	local geoLatitude = (lat / tau) * 360 + 23.5
	local clockTime = (lon / tau) * 24 - 6

	Lighting.GeographicLatitude = geoLatitude
	Lighting.ClockTime = clockTime % 24

end)

Oh, my other post? That’s a mess of scripts I’ve scoured from across the forums and combined them :p
There’s definitely redundant code there :sweat_smile:

Funny I do that too … them are way to hardcore for me. :rofl: Glad you found where to edit.

1 Like

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