Blinking emergency light that loops when a value is true

Hii!!

  1. What do you want to achieve?
    A blinking emergency light that loops when a value is true, something like this
    https://gyazo.com/44d77208097564d0b3598e06cf4bd90c

  2. What is the issue?
    I can’t find a way to make it loop

local hikarivalue = game.Workspace.EmergencyHikari
local hikari = script.Parent.ehikariyo

local function ehikari()
	if hikarivalue.Value then
		hikari.BrickColor = BrickColor.new("Bright red")
		wait(1)
		hikari.BrickColor = BrickColor.new("Really black")
		wait(1)
	else
		hikari.BrickColor = BrickColor.new("Really black")
	end
end

hikarivalue.Changed:Connect(ehikari)

https://gyazo.com/5ef162d3944284fb86c85e9db897bb4b

  1. What solutions have you tried so far?
    A somewhat temporary solution I’ve made is duplicate the blink code but I don’t think it’s quite a good solution since if the code ends it needs to be re-clicked again. Not a solution to it but I’ve also tried adding “while true do” that I’ve seen in a dev forum post but it doesn’t seem to work. Any help would be appreciated, thank you!

Two scripts, a part to flash and a bool for a trigger.

Script inside a Really black part

Flasher
local hikarivalue = game.Workspace.EmergencyHikari
local hikari = script.Parent

local function ehikari()
	while hikarivalue.Value do
		hikari.BrickColor = BrickColor.new("Bright red")
		wait(1)
		hikari.BrickColor = BrickColor.new("Really black")
		wait(1)
	end
	hikari.BrickColor = BrickColor.new("Really black")
end

hikarivalue.Changed:Connect(ehikari)

Script changing a bool on workspace.

Trigger
local hikarivalue = game.Workspace.EmergencyHikari
task.wait(10)
hikarivalue.Value = true
task.wait(10)
hikarivalue.Value = false
task.wait(10)
hikarivalue.Value = true
task.wait(10)
hikarivalue.Value = false
task.wait(10)

If bool is true it flashes.

2 Likes

This worked! Thank you so much!!

I haven’t tried this one yet but thank you anyways!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.