Bindable event isn't receiving?

I have 2 scripts, I’ve checked, the bindable event does fire. It isn’t receiving in the 2nd script, and I don’t know why. Its the same event, everything is enabled, and both scripts have access.

No solutions I’ve found here, might not have looked enough though. I even checked the documentation, which didn’t help.

first script:

local badge = script.Parent
local clickDetector = badge.ClickDetector
local rs = game:GetService("ReplicatedStorage")
local event = rs.RemoteEvents.ShopEvents.ShopItemClicked
local menuEvent = badge.Parent.TweenMenuUp
local itemClickEvent = badge.Parent.ItemClicked
local badgeStatsEvent = badge.Parent.Shop3DUI.SetBadgeStats

local itemName = "RedBadge"
local itemDesc = "This is a test description."
local price = "150"

clickDetector.MouseClick:Connect(function(player)
	local itemPos = badge.Position
	event:FireClient(player, itemPos)
	clickDetector.MaxActivationDistance = 0
	badge.HighlightScript.Enabled = false
	badge.Highlight.OutlineTransparency = 0
	local item = badge
	itemClickEvent:Fire(item)
	badgeStatsEvent:Fire(itemName, itemDesc, price)
	script.Enabled = false
	task.wait(0.1)
	menuEvent:Fire()
end)

second script:

local event = script.Parent.SetBadgeStats

event.Event:Connect(function(itemName, itemDesc, price)
	print(itemName .. " costs " .. price)
end)
6 Likes

Are they both server scripts or both client scripts? Bindable events can’t go between server and client.
Also if you put a print in the second script, above where it connects to the event do you see that print?

1 Like

They are both server scripts, in the same folder (albeit different parents)
and no, it doesn’t print anything.

2 Likes

try this

local event = script:WaitForChild("SetBadgeStats")

event.Event:Connect(function(itemName, itemDesc, price)
	print(itemName .. " costs " .. price)
end)
2 Likes

Just tried, still didn’t work.

2 Likes

Well of the print above the connect on the second script doesn’t show up then that means the script isn’t running. And so doesn’t connect.
Are they in ReplicatedStorage by chance?
Or are the modes/RunContexts between the two scripts different?

2 Likes

Modes are the same, they’re both inside workspace. Also both scripts are enabled

1 Like

This is just a throw in the dark but it could be because you are disabling the script.

badgeStatsEvent:Fire(itemName, itemDesc, price)
script.Enabled = false -- here
task.wait(0.1)
menuEvent:Fire()

I’m assuming its calling it but then stops before it can actually call it since it immediately cancels it. Again, this is just an assumption, I highly doubt that is the problem, though you should comment it out just to double check.

Also also, anything below the script.Enabled = false wouldn’t run since disabling the script will essentially stop the script from running

2 Likes

It for some reason is running menuEvent even after the script disables itself, and yeah, that also didn’t work, but thanks for commenting

2 Likes

can you show a picture of the the explorer tab showing the model the stuff it?

2 Likes

image
the script that isn’t working is NameSetter, and the click script gets enabled, can and does run without issue, so yeah

2 Likes

Sorry for the late reply went to get some food,

anyways, try printing something outside the function, just to see if it does get enabled

2 Likes

Outside the function it does print, its just genuinely not receiving the event for some reason

2 Likes

Just to note that it is an awful code bro.
It is super unsafe and you better to disconnect connection.
.MaxActivationDistance = 0 will do nothing really
It can be easily bypassed by an exploiter
Nothing stops client from firing signal again.
Also why would you do that in a server anyways?

Also what the purpose of variable “item”? it does nothing LOL
Also please use custom Signal library at this point
BadSignal for example
BindableEvents is bad perfomance wise

2 Likes

I know it is, im still learning, the unused variable is because the code itself is unfinished, and idk what custom signal library is because im not good at scripting, but thanks for telling me abt it

3 Likes

Yeah you do have a point, the code is unclean, was actually gonna tell him to put it all in 1 code. But you’re wrong on a few things,

  1. this is a BindableEvent, not a RemoteFunction, he doesn’t need to add anything to prevent anything.
  2. What do you mean by “why would you do that in a server anyways?” It’s using click detectors, you should be controlling that on the server.
  3. .MaxActivationDistance = 0 does do something, it, as it says, sets MaxActivationDistance to 0, basically meaning you can’t click on it. Not sure why he’s doing that, not gonna worry about it right now either.
  4. Don’t go telling people to use an outside source, lots of people like making their code from scratch.
  5. BindableEvents aren’t bad for performance. I’m not sure where you got that from.

Though you did mention one thing that went over my head, the MaxActivationDistance = 0 could be the cause of the script not working.

That understandable
Its a good practise to avoid using server script for UI or any changes that dont have to be replicated to all clients.
For Server/Client communication look up RemoteFunction and RemoteEvents

As of signal libraries i would recomend you using BadSignal for something more to be professional and very light weight or using GoodSignal if you are a begginer
I surpriced how ironic this 2 names are tbh LOL;

Main reason why people made them is becouse of Defered Signal implementation from roblox
Hower that doesn’t affect you if you use Imideat Signal engine from roblox;
Also using Custom signal library creates a bit lesser overhead than roblox’s bindable event as since it doesnt require you to allocate unneeded memory for whole instance

1 Like

Everything wrong bro.
You clearly don’t understand how signals work at all.
Also please don’t treat me as if im blind and dont see a differance between BindableEvent and RemoteEvent; Im not trying to being rude but please do research before trying to prove someone “wrong”
It is not very hard to open studio and check can be signal be fired from client after setting MaxDistance to 0, right?
Everything else is just face palm :man_facepalming: and complete not understanding of engine.

Not gonna reply to anything you say after this since I don’t want to make replies unrelated to the topic.

Anyways, it appears you didn’t read anything I said since you didn’t even mention one thing correctly about what I said,

Yes, I know it’ll make it so you can’t click the object, I literally said that on point 3. Why I said that was cause you said it “will do nothing really” which is completely wrong. It is doing something and I’m assuming it’s the cause of the problem.

And seeing as you didn’t provide any sources that explains how BindableEvents are bad for performance and looking up “roblox studio are BindableEvents bad for performance” will literally give you sources saying that aren’t bad. I’m going to assume you didn’t do any research on anything. If I’m wrong please show me a source rather then spreading misinformation.

Here is sources: source1, Ok more reliable source this time im fr :fire: source2

Also i explained everything right; Please dont forget that point of this post is to help OP and not “explain to you why BindableEvent is better or worse”

Im trying to help people understand the issue to avoid that in the future and not just HERE IS THE ANSWER
More over there is a lot of errors in OP’s code that they may stumble upon in the future such as unsafe code from exploiter attacks.

@rickrolledlololXD2 issue is fairly simple you never fire this event in your code but likely fire the other events.