Alarm Lights are getting stuck after 5 seconds

What do you mean, call this on the server?

Show me where you use .StartAlarms.

1 Like
require(game.ServerScriptService.Modules.Alarm).AlarmStart(Color3.new(1, 0.701961, 0), "rbxassetid://1211986303")

You can use this anywhere on a script.

1 Like

No, I mean the script location. I am asking where you call the function. If it can only be called on the server, make a new RemoteEvent called “AlarmStatus” and I can show you how to program it.

1 Like

I think it is only server-side.

Alright, I’ll show you how to convert your system to TweenService.

  1. Add a new RemoteEvent in ReplicatedStorage called “AlarmStatus”

  2. Change your module script to this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local AlarmStatus = ReplicatedStorage.AlarmStatus

local module = {}

function module.AlarmStart(color:Color3, sound)
	AlarmStatus:FireAllClients(true)

	for i, v in workspace.Systems.Announcers:GetChildren() do
		if v:IsA("Model") then
			for i, v in v.Light:GetChildren() do
				if v:IsA("SpotLight") then
					v.Enabled = true
					v.Color = color
				end
			end
			
			v.Light.Material = Enum.Material.Neon
			v.Light.Color = color
			v.Light2.Color = color
			v.SoundMain.Alarm.SoundId = sound
			v.SoundMain.Alarm:Play()
		end
	end
end

function module.StopAlarms()
	AlarmStatus:FireAllClients(false)
	
	for i, v in workspace.Systems.Announcers:GetChildren() do
		if v:IsA("Model") then
			for i, v in v.Light:GetChildren() do
				if v:IsA("SpotLight") then
					v.Enabled = false
				end
			end
			
			v.Light.Material = Enum.Material.SmoothPlastic
			v.SoundMain.Alarm:Stop()
		end
	end
end


return module
  1. Add a new LocalScript in StarterPlayerScripts, and paste this inside:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

--//Variables
local AlarmStatus = ReplicatedStorage:WaitForChild("AlarmStatus")
local Announcers = workspace:WaitForChild("Systems"):WaitForChild("Announcers")

--//Controls
local alarmsEnabled = false

--//Functions
AlarmStatus.OnClientEvent:Connect(function(value)
	alarmsEnabled = value
	
	if not alarmsEnabled then
		return
	end
	
	for i, v in Announcers:GetChildren() do
		if v:IsA("Model") then
			local rotationPart = v.SoundMain
			
			while alarmsEnabled do
				local rotationTween1 = TweenService:Create(rotationPart, TweenInfo.new(3, Enum.EasingStyle.Linear), {
					CFrame = rotationPart.CFrame * CFrame.Angles(0, math.rad(180), 0)
				})

				rotationTween1:Play()
				rotationTween1.Completed:Wait()

				local rotationTween2 = TweenService:Create(rotationPart, TweenInfo.new(3, Enum.EasingStyle.Linear), {
					CFrame = rotationPart.CFrame * CFrame.Angles(0, math.rad(180), 0)
				})

				rotationTween2:Play()
				rotationTween2.Completed:Wait()
			end
		end
	end
end)

I’m not sure if the :IsA(“Model”) is necessary because your explorer pictures have way too little information for me to know. Make sure to remove all HingeConstraints, and just anchor the part.

Uh, that did something a little interesting…
https://files.catbox.moe/is0i3l.mp4

Oh wait, I think I see what happened…

It’s probably the wrong orientation. Right click show orientation indicator and send a picture.

No, I think you didn’t rotate the right part. The Part was called LightBase

Well, maybe that too.

Oops, yea I referenced the wrong part.

LocalScript Code:

--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

--//Variables
local AlarmStatus = ReplicatedStorage:WaitForChild("AlarmStatus")
local Announcers = workspace:WaitForChild("Systems"):WaitForChild("Announcers")

--//Controls
local alarmsEnabled = false

--//Functions
AlarmStatus.OnClientEvent:Connect(function(value)
	alarmsEnabled = value
	
	if not alarmsEnabled then
		return
	end
	
	for i, v in Announcers:GetChildren() do
		if v:IsA("Model") then
			local rotationPart = v.LightBase
			
			while alarmsEnabled do
				local rotationTween1 = TweenService:Create(rotationPart, TweenInfo.new(3, Enum.EasingStyle.Linear), {
					CFrame = rotationPart.CFrame * CFrame.Angles(0, math.rad(180), 0)
				})

				rotationTween1:Play()
				rotationTween1.Completed:Wait()

				local rotationTween2 = TweenService:Create(rotationPart, TweenInfo.new(3, Enum.EasingStyle.Linear), {
					CFrame = rotationPart.CFrame * CFrame.Angles(0, math.rad(180), 0)
				})

				rotationTween2:Play()
				rotationTween2.Completed:Wait()
			end
		end
	end
end)

Yep, that works. I need to add the weld constraint back to the light tho and it should work. Thanks for helping out.

No problem. If there are no more bugs, you can set my reply as the solution. Have a good day!

Ok actually, only one of the alarms was spinning but the rest were not.

I forgot to use task.spawn to encapsulate that loop.

LocalScript Code:

--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

--//Variables
local AlarmStatus = ReplicatedStorage:WaitForChild("AlarmStatus")
local Announcers = workspace:WaitForChild("Systems"):WaitForChild("Announcers")

--//Controls
local alarmsEnabled = false

--//Functions
AlarmStatus.OnClientEvent:Connect(function(value)
	alarmsEnabled = value

	if not alarmsEnabled then
		return
	end

	for i, v in Announcers:GetChildren() do
		if v:IsA("Model") then
			local rotationPart = v.LightBase
			
			task.spawn(function()
				while alarmsEnabled do
					local rotationTween1 = TweenService:Create(rotationPart, TweenInfo.new(3, Enum.EasingStyle.Linear), {
						CFrame = rotationPart.CFrame * CFrame.Angles(0, math.rad(180), 0)
					})

					rotationTween1:Play()
					rotationTween1.Completed:Wait()

					local rotationTween2 = TweenService:Create(rotationPart, TweenInfo.new(3, Enum.EasingStyle.Linear), {
						CFrame = rotationPart.CFrame * CFrame.Angles(0, math.rad(180), 0)
					})

					rotationTween2:Play()
					rotationTween2.Completed:Wait()
				end
			end)
		end
	end
end)

Ok, That works. Thanks again for the help.

(hopefully this won’t happen again lol)

Could you set my reply as the solution if it worked?

whoops, I completely forgor to do that :skull:

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