我该如何闪烁灯光?

问题描述

好吧,所以在roblox中,我一直试图发出闪烁的灯光,但似乎不起作用。因此,我尝试查找第一行中的错误,但是..它似乎不起作用,而且我似乎也找不到。

while true do
    math.randomseed(tick())
    local Brightness = math.random(0.1,1)
    local Light = script.Parent
    local SpotLight = Light.SL
    local RandomPause = (math.random(0.5,5))
    wait(RandomPause)
    SpotLight.Brightness = Brightness
    wait (RandomPause)
    SpotLight.Brightness = Brightness
end

解决方法

  1. 将聚光灯插入零件

  2. 将此脚本插入到该部分中:

    local spotlight = game.Workspace.Light.SpotLight
    
    while true do 
    spotLight.Enabled = true
    wait(2)
    spotLight.Enabled = false
    wait(0.1)
    spotLight.Enabled = true
    wait(0.3)
    spotLight.Enabled = false
    wait(0.5)
    
    end
    
    

您可以根据需要编辑“等待(时间)”,以加快或减慢闪烁。