0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Luau】昼夜システムの作り方

Posted at

コード


-- 昼夜システムの設定
local DAY_LENGTH = 20 -- 昼の長さ(秒)
local NIGHT_LENGTH = 10 -- 夜の長さ(秒)

local Lighting = game:GetService("Lighting")

local function setDay()
    Lighting.ClockTime = 12 -- 昼
    Lighting.Brightness = 2
    Lighting.Ambient = Color3.new(1, 1, 1)
end

local function setNight()
    Lighting.ClockTime = 0 -- 夜
    Lighting.Brightness = 0.5
    Lighting.Ambient = Color3.new(0.1, 0.1, 0.2)
end

local function dayNightCycle()
    while true do
        setDay()
        wait(DAY_LENGTH)
        setNight()
        wait(NIGHT_LENGTH)
    end
end

-- サイクル開始
spawn(dayNightCycle)

解説

このコードの場合では、20秒⇒夜⇒10秒⇒昼のように、なっています。
これはただ単純に、ClockTimeをいじるだけで完成できるので初心者でも十分に理解できます

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?