RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"if npc get closer to the light the light will start to flicker"
-- server script local npc = game.Workspace.NPC local lightPart = game.Workspace.LightPart local flickering = false local function distanceBetween(a, b) return (a.Position - b.Position).magnitude end local function flickerLight() if not flickering then flickering = true local light = lightPart.PointLight while flickering do light.Enabled = not light.Enabled wait(math.random(1, 10) / 10) end end end while true do local distance = distanceBetween(npc.HumanoidRootPart, lightPart) if distance < 10 and not flickering then flickerLight() elseif distance >= 10 and flickering then flickering = false lightPart.PointLight.Enabled = true end wait(0.5) end