脚本可用在LocalScript,也可以用在Script,区别就是:LocalScript是本地脚本,昼夜变化比较流畅,但是和其他玩家不会同步,Script是服务器脚本,有时候会因为延迟问题导致不流畅,但是会同步所有玩家的昼夜变化。
local lighit = game.Lighting
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
300, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.In,
0, -- RepeatCount (小于零时 tween 会无限循环)
false, -- Reverses (tween 完成目标后会反转)
0 -- DelayTime
)
local a = -3
local tween1 = TweenService:Create(lighit, tweenInfo, {ClockTime = 24,ExposureCompensation = 0})
local tween2 = TweenService:Create(lighit, tweenInfo, {ClockTime = 12,ExposureCompensation = 0})
tween1:Play()
tween1.Completed:Connect(function(playbackState)
lighit.ClockTime = 0
tween2:Play()
end)
tween2.Completed:Connect(function(playbackState)
tween1:Play()
end)