Event not working properly?

  1. What do you want to achieve? I’m trying to make a GUI show up when an event is fired if you’re on a team.

  2. What is the issue? I don’t get any errors, so I’m unsure asto what’s wrong here.

  3. What solutions have you tried so far? I’ve searched it up on the DevForum but have found nothing that has helped me in this situation.

Script firing the event

local Part = script.Parent
local ClickDetector = Part.ClickDetector
local MoneySpawner = Part.Parent.Parent.MoneySpawnerPoint
local Money = game.ServerStorage.Money
local Event = game.ReplicatedStorage.ATMRobEvent
local AlreadyRobbed = false

function onClick(player)
	if Part.BrickColor == BrickColor.new("Lime green") and AlreadyRobbed == false then
		Part.BrickColor = BrickColor.new("Really red")
		AlreadyRobbed = true
		for count = 1,3 do
			MoneyClone = Money:Clone()
			MoneyClone.Parent = game.Workspace
			MoneyClone.CFrame = MoneySpawner.CFrame
		end
		Event:Fire(player.Name)
		script.Parent.Parent.Sound:Play()
	end
	if Part.BrickColor == BrickColor.new("Really red") and AlreadyRobbed == true then
		wait(30)
		AlreadyRobbed = false
		Part.BrickColor = BrickColor.new("Lime green")
	end
end

ClickDetector.MouseClick:Connect(onClick)

Script receiving the event

local Event = game.ReplicatedStorage.ATMRobEvent
local Player = game.Players.LocalPlayer

function onEventPlayed()
	print("Working 1")
	if Player.Team == game.Teams["Patrol Unit"] then
		print("Working 2")
		script.Parent.Visible = true
	end
end

Event.Event:Connect(onEventPlayed)

^ This is a Local Script

1 Like

I don’t believe you’re including the script which is yielding an error; you need to include the script attached to AlertGui.Frame

1 Like

Wait, sorry I accidentally put the wrong error. Let me edit it
That was the error I got before, I had updated the script to what it is and currently don’t get any errors.

If the top script is a server one, then you will need to use RemoteEvent which is fairly similar to BindableEvent

1 Like