Alert System Help

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? To get a way of alerting everyone on the server that there is a fire.

  2. What is the issue? So I’m making a script that will send an alert to all players, whether it be a chat message or gui that comes up. I’ve got another script that will update a Boolean value called “FireActive” to true when the fire starts. The know the script works and the function works since I get a message in cmd saying “There is a fire!”. But the chat message doesn’t work. From what I’ve looked up, it needs to a localscript for it to work, however if I set it as a localscript it doesn’t run at all. The “FireActive” and the code bellow is in the models group.

  3. What solutions have you tried so far? I’ve looked online and haven’t found anything, I’ve also asked the roblox assistant.

-- Script for sending out a serverwide notification when FireActive is true
parent = script.Parent

local function sendAlert()
	print("There is a fire!")
	game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
		Text = "Fire alert! Fire detected at: "..parent.Name,
		Color = Color3.fromRGB(255, 0, 0),
		Font = Enum.Font.SourceSansBold,
		FontSize = Enum.FontSize.Size24
	})
end

while true do	
	if parent.FireActive.Value == true then
		sendAlert()
		wait(100)
	else
		print("fire not started yet")
		wait(12)
	end
end
2 Likes

You should track when the fire starts on the server. And I’d recommend not using a boolvalue because uh I think it takes up more memory or smthn like that

Then you should create a RemoteEvent and use FireAllClents

Then you can use StarterGui:SetCore

You should prolly imo use a wait task.wait() loop

I’ll give you a lil example:

-- ON THE SERVER (ServerScriptService)
local RE = path.to.remote
-- detect when the fire starts
--[[
i saw you had a parent property, I’m not sure what that could be though so I’ll assume
that you can get it on the server
]]
RE:FireAllClients(parent)

Hi, many thanks for the response. So I have a script in serverscriptservice that picks a random building and then it’ll set FireActive to true and set alight the building. So would you recommend I store whether a fire is active in that script then from there I send an alert, the only problem is that that script is not a local script. The parent property just links back to the parent so the name of the model so I’m able to tell where the fire is

1 Like

Like @Doomcolp said, use a RemoteEvent, and connect a LocalScript in StarterPlayerScripts, or if you have a GUI for it as well, StarterGui. From there, you can interact with the Core Scripts.

Just a quick question: Are you using the new or old chat?

2 Likes

Yeah I think that, that would be more memory efficient even if it’s just a small optimization

Hm then you’d have to create a LocalScript or use an existing one along side the server Script

Gotchu, I thought it was a LocalScript at the time and just wanted to make sure you could still access whatever you needed to

If you’re using the new chat system, you’ll have to create a TextChannel and use TextChannel:SendAsync instead of StarterGui:SetCore("ChatMakeSystemMessage")

No, that’s not really how you would use it. It’s TextChannel:DisplaySystemMessage(), and you could just use the default text channels. That’s all I was checking for, just in case @AtheonsYoshi was using an old chat interaction on the new chat. :slight_smile:

1 Like

Mb haven’t used it in a while. I must’ve mixed it up with HttpService’s functions

1 Like

Im using the new chat. I can change it if it will work on the old chat?

No, don’t change it back. It’s simpler on the new one. To display the message to everyone, e.g. in the main TextChannel, you can do the following (in a LocalScript):

local tcs = game:GetService("TextChatService")

tcs.TextChannels.RBXGeneral:DisplaySystemMessage("Message content here")

What you have currently will work on the old chat.

1 Like

Would the message show in studio when I test it or will I need to publish and test the game from roblox for it to show in chat?

It should show both in Studio and in Roblox if done correctly. Let me know if you get any errors :slightly_smiling_face:.

Many thanks, I will let you know.

1 Like

Many thanks I’ve got it working. However, I’m struggling to get it to also show where the building is located. I’ve added some code to get it to make a new string and sent it to replicated storage that has the value of the building picked, this works I can see that when testing. But the code to send a message only shows whats in “”

local tcs = game:GetService("TextChatService")

game.ReplicatedStorage.Fire.OnClientEvent:Connect(function() 
	tcs.TextChannels.RBXGeneral:DisplaySystemMessage("FIRE LOCATED IN: ", game.ReplicatedStorage.Building.Value)	
end)

Just concatenate it - You can also colour the message as well, if you want.

tcs.TextChannels.RBXGeneral:DisplaySystemMessage("<font color=\"rgb(255, 0, 0)\">FIRE LOCATED IN: "..game.ReplicatedStorage.Building.Value.."</font>")

This code should send a red chat message.

1 Like

You’re amazing. Thank you very much!

1 Like

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