Alarm System (GUI)

Hi there, I’m currently working on a new alarm system for my game. With this being said, I’m having trouble connecting the GUI so it will display for all users when a certain brick is touched.

The way I want is connected is so that it displays the player that hit it’s name as the top part of the GUI says “The bank has been robbed by:” (this is also connected to a sound that plays from the brick that is touched.

Thanks in advance to anybody who can help me with this.

Current code so far:

    local debounce = false
Light = script.Parent.PointLight -- PointLight
function onHit(hit)
local human = hit.Parent:findFirstChild("Humanoid")
local name = hit.Parent:findFirstChild("Name")
if (human ~= nil) and debounce == false then

        debounce = true
game:GetService("Players"):GetPlayers()PlayerGui.Robbery.Enabled = true
game:GetService("Players"):GetPlayers().PlayerGui.Robbery.Frame.User.Text = name


wait (2)
	script.Parent.Sound:Play()
	Light.Enabled = true
	wait (2)
	Light.Enabled= false
	wait (2)
	Light.Enabled = true
	wait (2)
	Light.Enabled = false
	wait (2)
	Light.Enabled = true
	wait (2)
	Light.Enabled = false
	game.StarterGui.Robbery.Enabled = false
	

        debounce = false
end
end

    script.Parent.Touched:connect(onHit)
1 Like

The function GetPlayers returns a table, not a instance, so you can’t just get their GUI like that, as it would spit out an error. Assuming that the script is on the server, you would either use a RemoteEvent to or store the bank robbery message on Replicated storage and have the clients listen to that.

2 Likes

Do you happen to have Discord and could run me through this quickly? I can throw you 500-1,000 R$ for your help. I’m hoping to get this done fast, only reason I’m willing to throw in some R$. It’d be via Group funds as well.

Thanks!

I am currently unavailable. However, you can go hire someone on the Collaboration category.

1 Like

Alright - if nobody is able to guide me further I’ll look into that. In the meantime, I’ll try my best to do this via RemoteEvent.

1 Like

Still no clue on how to do this, I may not be firing the RemoteEvent right… Really frustrating, if anybody is able to help me with this. I just don’t know how to make it so it displays for all players.

Can you share more details on what your problem is?

	local human = hit.Parent:findFirstChild("Humanoid")
	local name = hit.Parent:findFirstChild("Name")
	if (human ~= nil) and debounce == false then

                debounce = true

	

wait (2)
game.ReplicatedStorage.Alarm:FireAllClients()


		script.Parent.Sound:Play()
		Light.Enabled = true
		wait (2)
		Light.Enabled= false
		wait (2)
		Light.Enabled = true
		wait (2)
		Light.Enabled = false
		wait (2)
		Light.Enabled = true
		wait (2)
		Light.Enabled = false
		game.StarterGui.Robbery.Enabled = false
		

                debounce = false
	end
end

script.Parent.Touched:connect(onHit)

So I’ve made some updates to that, which is a server script connected to the brick that is touched when alarm goes off.

Here is the script I tried connecting it to via RemoteEvent, which is also a server script:

	game.ReplicatedStorage.Alarm.OnServerEvent:Connect(function()
for i,player in pairs(game.Players:GetPlayers()) do
	    player.PlayerGui.Robbery.Enabled = true
	end

The event should be connected on the client, not the server.

Sorta like this:

--[Client code]
Event.OnClientEvent:Connect(function(RobberName)
 --code
end)

--[Server code]
Event:FireAllClients(Robber.Name)

Here is a tutorial!

It’s working perfectly now, thank you so much for the help!

2 Likes