How to receive when a BindableEvent is fired

How would I receive when a BindableEvent is fired and what was fired in it?

Maybe these could help-

He’s not asking why it’s not being received. He’s asking how to receive it when it’s fired.

You can use BindableEvent.Event to know when one fires. It functions like a regular event.
You can pass arguments in BindableEvent:Fire() for the event to receive.

2 Likes

This is my localscript, which fires the bindable event:

local DeviceModule = {
	Devices = {
		Computer = {game:GetService('UserInputService').MouseEnabled and game:GetService('UserInputService').KeyboardEnabled},
		Mobile = {game:GetService('UserInputService').TouchEnabled},
		Console = {game:GetService('UserInputService').GamepadEnabled}


	},


}

function GetDevice()
	game.Players.PlayerAdded:Connect(function(plr)
		local device
		local event = game.ReplicatedStorage.NameTagNetwork.DeviceEvent
		if DeviceModule.Devices.Computer then
			device = 'Computer'
		elseif DeviceModule.Devices.Mobile then
			device = 'Mobile'
		elseif DeviceModule.Devices.Console then
			device = 'Console'
			event:Fire(device)
		end
	end)
end




return DeviceModule

My serverscript receiving it:

local function onevent(plr, device)
			if plr == plr then
				if device == 'Computer' then
					tag.overhead.Icons.logo.Image = devicemodule2.PlatformImages.Desktop
				elseif device == 'Mobile' then
					tag.overhead.Icons.logo.Image = devicemodule2.PlatformImages.Mobile
				elseif device == 'Console' then
					tag.overhead.Icons.logo.Image = devicemodule2.PlatformImages.Console
				end
			end
		end
		
		event.Event:Connect(onevent)

BindableEvent can’t communicate from client to server, use remote events instead

Switch the BindableEvent to a RemoteEvent and simply…

Change this line ^
to this: event:FireServer(device)

and change…

This line ^
to this: event.OnServerEvent:Connect(onevent)

2 Likes