Help with bindable events

I’m learning about bindable events but the .Event doesn’t seem to happen. Can anyone help?
This part works and fires correctly:

local button = script.Parent
local event = game.ReplicatedStorage.DisplayPet
button.Activated:Connect(function()
	event:Fire(button)
	print(event,"fired",button)
end)

This part does not print

local displayevent = game.ReplicatedStorage.DisplayPet
displayevent.Event:Connect(function()
	print("Event Recieved")
end)

Where/what are your scripts? If you’re activating client-side, it won’t trigger the BindableEvent on the server.

2 Likes

both are client sided scripts. One script is inside a text button in the player’s gui and the other is another local script in the same gui but managing the whole thing

It looks as if it should work, I don’t see any issues with the code. Maybe it’s something else with the setup? Is your code actually reaching the point where that event connection is made, in the event receiver code?

1 Like

it’s one event in replicated storage. Both scripts are correctly referencing the same event. I’ll keep testing for any life out of that receiver code and let you know

1 Like

Can you give path of both of the scripts? Like game.StarterGui.scriptname

1 Like

Where is located the second script?

1 Like

the event that works correctly is initially inside replicated storage and is disabled. It’s cloned by the main gui script and enabled after being parented to a text button in the player’s gui:
game.StarterGui.PetInventory.List.Holder.ScrollingFrame.TextButton.Displayer

the gui that’s not recieving is the main gui:
game.StarterGui.PetInventory.List.InventoryHandler

What classname is the InventoryHandler?

1 Like

it’s a local script (extra characters)

Can you add debugging print after the :Connect to the event to print something so you know it has connected

1 Like

Can you take a screenshot of the environment where the scripts and the event are located?

2 Likes

that’s the problem. it prints in the firing event but not in the receiving event I have added prints on both sides

Not the in connection callback, but after the connection was connected

local displayevent = game.ReplicatedStorage.DisplayPet
displayevent.Event:Connect(function()
	print("Event Recieved")
end)
print("connected")
2 Likes

oh yeah I added that. It prints correctly when inside one of the functions I created. But when I take it outside the function it doesn’t print. For that I double checked that it’s not referenced inside the function and it is referenced outside the function at the start of inventory handler

These are both scripts (inside the player GUI while play testing)

Can you possibly make a video of you pressing the button and everything? With the output opened.

2 Likes

alr very weird fix but I kinda fixed the script?

I added a debugging print at the very start of the final part of my script where all the events are received. Somehow it printed there correctly so I just moved the receiving part to the start of the events and now it receives the event. Anyone know a reason for that?

2 Likes

this is the part that receives events for me:

displayevent.Event:Connect(function()
	print("Event Recieved")
end)
setupplayer(LocalPlayer)
updateplayer(LocalPlayer)
createpets()
updateevent.OnClientEvent:Connect(function()
	updateplayer(LocalPlayer)
	createpets()
end)

1 Like

There’s probably an infinite loop preventing further code from running, or something that is indefinitely yielding. You could add a load of prints to work out where

2 Likes

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