It's a lens flare GUI, and I'm trying to see if I can make a moon lens flare just by changing a variable.
local camera=workspace.CurrentCamera
local host=script.Parent
local lFlares={}
local collision
for q,w in pairs(host:GetChildren()) do
if w.Name:sub(1,9)=="LensFlare" then
lFlares[w]=tonumber(w.Name:match("LensFlare(%-?.+)"))
end
end
function findFlareCoord(cordFrame,sunPos)
local setCoord=cordFrame:pointToObjectSpace(sunPos)
local fov=math.atan(math.rad(camera.FieldOfView))
local z=-setCoord.z
if z>0 then
local x=(setCoord.x/fov/1.2)/(z+1)*(host.AbsoluteSize.y/host.AbsoluteSize.x)
local y=(setCoord.y/fov/1.2)/(z+1)*-1
return x,y,true
else
return 0,0,false
end
end
local stepped = game:GetService("RunService").Stepped
while true do
local x,y,z=findFlareCoord(camera.CoordinateFrame,camera.CoordinateFrame.p+game.Lighting:GetSunDirection()*5)
dist = (camera.CoordinateFrame.lookVector - game.Lighting:GetSunDirection()).magnitude * .3
local sunCast = Ray.new(camera.CoordinateFrame.p, game.Lighting:GetSunDirection() * 999)
local hitPart, hitPos = workspace:FindPartOnRayWithIgnoreList(sunCast,{game.Players.LocalPlayer.Character, camera})
collision = hitPart and true or false
if z and (game.Lighting:GetMinutesAfterMidnight()>335 and game.Lighting:GetMinutesAfterMidnight()<1105) and collision==false then
for lFlare,pos in pairs(lFlares) do
lFlare:TweenPosition(UDim2.new(0.5 + x*pos,-lFlare.AbsoluteSize.x/2,0.5+y*pos,-lFlare.AbsoluteSize.y/2),"Out","Quad",0.01,true)
lFlare.Visible=true
end
local shineTrans=(0.2-(math.abs(x+y)*0.5))
if shineTrans>=0.2 then
shineTrans=0.2
elseif shineTrans<=0 then
shineTrans=0
end
host.ShineOverlay.Transparency=1-shineTrans
print(x)
else
for lFlare in pairs(lFlares) do lFlare.Visible=false end
host.ShineOverlay.Transparency=1
end
stepped:wait()
end
