Bindable Event Not Firing

Stuff:

Bindable event located in Player Gui
image

Client Code meant to fire the Bindable Event
image

local char = script.Parent
local plr = game.Players:WaitForChild(char.Name)
local buildMess = plr.PlayerGui:WaitForChild("BuildMessage")

buildMess:Fire("You cannot build in that location, red outline shows this.")

Client code meant to detect the event and create said message:

bind.Event:Connect(function(mess) --client access to messaging
print("Recieved an Event")
if dDebounce then
print("Doing the message!")
message(mess)
end
end)

Issue:
Nothing happens, I don’t even receive “Received an Event”
Not even when I do this:
image

2 Likes

There’s an awful lot of code missing, from what I can see the issue would be elsewhere. Can you include more code?

(also small tip, it’s better practice to use game:GetService() rather than indexing services directly, but just a small thing)

3 Likes

Are you sure the script handling the .Event is not disabled?

Loads of stuff could be improved here:

to: local plr = game:GetService(“Players”).LocalPlayer

Why is this BindableEvent stored in StarterGui unless more than one LocalScript is accessing it?

Like @Elttob said, there is a lot of missing things that might be affecting it.

I am very sure, because the script handles many other things and the other things are working very well.

I would include more code, but whenever I Ctrl+C and Ctrl+V into the reply box, I always get weird extra separating lines and quotes are replaced with (& quot ; ) Ignore spaces

Here is what I mean
local char = script.Parent

local hum = char:WaitForChild("Humanoid")

local buildComs = game.ReplicatedStorage.Build

local plr = game.Players:WaitForChild(char.Name)

local buildMess = plr.PlayerGui:WaitForChild("BuildMessage")

local mouse = game:GetService("Players").LocalPlayer:GetMouse() --i need to know where he is going to build

local ingame = plr.stats.isInGame

local isBuilding = plr.PlayerGui.FlatUI.BuildMode.LocalScript.Building --from the gui

local camera = workspace.CurrentCamera --so i can store our outline and make it client based

local buildrange = 45

local cost = 5

local wood = plr.stats.ShopValues.Wood

local woodHP = plr.stats.Attributes.WoodHP

local rot = 0;

local canBuild = false; --for the terrainlimitations

local terrainLimit

local debounce = true; 

I don’t really know where else to put it. Would you put it in replicated storage? And I wanted it to be more organized…

Is there more in the event receiving script that we can’t see? You could create a pastebin with the script or save the game as a .rbxl and then upload it here instead of trying to paste it in. There’s little help we can do without seeing any more of the script.

I can provide some pictures

Character Script:
image

Code




GUI Script:

Code




It’s rather messy

You should try embedding the code within two sets of ```

3 Likes

if you can’t send the code without it messing up, just link a pastebin and it’ll make it easier on everyone.

Rather than adding prints inside your event, try adding them outside. The way you’ve connected the BindableEvent doesn’t have any issue at all, so I suspect the primary issue is that some piece of code is obstructing the event from being hooked. Add a print above and below both the bindable fire statement and the event connection.

local char = script.Parent
local plr = game.Players:WaitForChild(char.Name)
local buildMess = plr.PlayerGui:WaitForChild("BuildMessage")

print("Preparing fire")
buildMess:Fire("You cannot build in that location, red outline shows this.")
print("Fired")

and

print("Connecting event")
bind.Event:Connect(function(mess) --client access to messaging
print("Recieved an Event")
if dDebounce then
print("Doing the message!")
message(mess)
end
end)
print("Connected")
2 Likes

Semi-Success:
image
I had to reorganize my script

However:
image
I do not get a “Event received” message

So my function doesn’t seem to work or fire…

Someone requested pastebins

The bindable event firer: Build Message Firer - Pastebin.com
image
Firing at lines 134-137

The bindable event receiver: Event Receiver - Pastebin.com
image
Receiving at lines 106-114

Fixed my issue, thanks guys for the help.

A bindable event does NOT fire in PlayerGui for some reason. Only in PlayerScripts. Makes organizing a little harder…

You may want to post a bug report regarding this if you have a confirmation that this is the case. That being said, BindableEvents should and do work in PlayerGui perfectly fine. In fact, I created a quick repro to test and the event was being received. It strings back to my original concern that it’s a part of your implementation and not the utilities themselves.

My implementation:
image

StarterGui LocalScript code:

local Event = script.Parent:WaitForChild("Event")

print("Starting connection")
Event.Event:Connect(function (message)
	print(message)
end)
print("Connected")

StarterPlayerScripts LocalScript code:

game:GetService("ContextActionService"):BindAction("A", function()
	game:GetService("Players").LocalPlayer.PlayerGui.Event:Fire("F press")
end, false, Enum.KeyCode.F)

Results:
image

Well, the only thing I changed in my scripts was the location of the Bindable Event. After that it worked smoothly. So unless there was too much clutter in the PlayerGui folder for the bindable event to fire, I dunno what’s going on…

And before you comment, I had checked profusely in the original script (before I moved the event to PlayerScripts) that the location I was specifying was correct.

Things don’t magically work if you change the location, aside from if the location is the very reason causing obstruction (such as putting an item in the wrong part of the hierarchy, like ServerStorage and trying to use a LocalScript on the object). There’s definitely an implementation problem that’s not being addressed. The root problem still exists, moving an object to another container isn’t a magical solution.

“Clutter” doesn’t prevent an event from being connected or firing. Checking is not enough, intensive debugging and rewriting at times is also required. There’s an implementation problem because BindableEvents are not incapable of working in PlayerGui.

Well, you can see the code and the massive amount of pictures I left. If you think there was an implementation problem, or still is, you can check.

If you want me to create a #development-support:requests-for-code-feedback post then I will, but I don’t really know how it could be an implementation issue when all I did was change locations of the event, change the location in the scripts and then it started working again.

What could the root problem be? The different container did end up being my magic solution, none of the code has been changed other than variables containing the event’s location (Now in “PlayerScripts”).

There is no such thing as magical solutions. I am almost certain that your code did not suddenly start working simply because you changed containers, there’s an underlying problem that I can’t determine and will probably need a physical file to play around with.

It would probably help for you to post a code feedback thread for code improvements so that the system actually does work, whether it’s direct improvements to the code or changing the implementation pattern.

Perhaps in the intended implementation, placing it in StarterPlayerScripts is fine, however what specifically I don’t agree with is

  • A. Saying that BindableEvents don’t work in StarterGui.
  • B. That something magically started working because of a container change. The problem is the code, not the location of an object. It’s just an object, the code is what gives it “life”.
1 Like

The same happened to me. So it kinda is based on luck at this point for GUI hefty games such as ours.