Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

my innovation-like warning light doesnt seem to turn off?

i tried for awhile to get it working but it wont :(

local sp = script.Parent
local light = script.Parent.LightPart

while true do
	workspace.GameData.Warn.Changed:Connect(function()
		if workspace.GameData.Warn.Value == 1 then
			light.SpotLight.Enabled = true
			light.SpotLight2.Enabled = true
			sp.Lamp.Sound:Play()
			for i=1 ,math.huge do
				light.CFrame = light.CFrame*CFrame.Angles(0, 0.01, 0)
				wait(0.1)
			end
		else
			light.SpotLight.Enabled = false
			light.SpotLight2.Enabled = false
			sp.Lamp.Sound:stop()
		end
	end)
	wait(1)
end

4 comments

0

Are you using a normal script or localscript? Also a loop isn't needed in this case.

0

I'm using a normal script, it works fine but it won't stop spinning

0

I added the while loop to see if i could get it to update and check the value

0

wish i could accept both your answers all of you were so helpful

1 answer

✓ Accepted answer

This is my solution

local sp = script.Parent
local light = script.Parent.LightPart

workspace.GameData.Warn:GetPropertyChangedSignal('Value'):Connect(function() -- Works more efficiently
	if workspace.GameData.Warn.Value == 1 then
		light.SpotLight.Enabled = true
		light.SpotLight2.Enabled = true
		sp.Lamp.Sound:Play()
		for i = 1, math.huge do
			light.CFrame = light.CFrame * CFrame.Angles(0, 0.01, 0)
			if workspace.GameData.Warn.Value ~= 1 then -- Check if the value is still 1
				break -- Stop the repetition
			end
			wait()
		end
	else
		light.SpotLight.Enabled = false
		light.SpotLight2.Enabled = false
		if sp.Lamp.Sound.IsPlaying then -- Check if the sound playing or not
			sp.Lamp.Sound:Stop()
		end
	end
end)

Be you sure to use a ServerScript!

For more questions put below in the commentaries.

This discussion is preserved as it was. New answers, comments, and votes are closed.