New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
0

# How i can use correctly the Bindable Events?

Edited 6 months ago

I have create a BindableEvent inside the Backpack, called "RefreshPetsEquipped"

I need close the PetsInvFrame when a player buy a gamepass.

In a LocalScript:

local RefreshPetsEquipped = player.Backpack:WaitForChild("RefreshPetsEquipped")

local function OnEquippedFrame()
PetsInvFrame.Visible = false
PetsFrame:ClearAllChildren()
EquippedFrame:ClearAllChildren()
end
RefreshPetsEquipped.Event:Connect(OnEquippedFrame)


Inside the Script i have add this when the purchase is correct:

local StarterPack = game:GetService("StarterPack")
local RefreshPetsFrame = StarterPack:WaitForChild("RefreshPetsEquipped")
---blablabla
print("Test")
RefreshPetsFrame:Fire()


I see the "Test" when i buy the Gamepass correctly, but the PetsInvFrame still visible. 100% sure i wrong with use the BindableEvent. Who can help me?

0 Errors in Output

1
Edited 6 months ago

It would seem like you're trying to communicate with the client using BindableEvents. If you have FilteringEnabled set to true, this is an impossible task.

You are also referencing the BindableEvent inside of the StarterPack, but for the player it's in the backpack so you wouldn't be connecting to the same event in the localscript that you would be firing in the server script.

I'm going to assume that you have FilteringEnabled set to true, in which case if you want to communicate with the client the best way is to use RemoteEvents.

You can try these

LocalScript

local RefreshPetsEquipped = game.ReplicatedStorage:WaitForChild("RefreshPetsEquipped")

local function OnEquippedFrame()
PetsInvFrame.Visible = false
PetsFrame:ClearAllChildren()
EquippedFrame:ClearAllChildren()
end
RefreshPetsEquipped.OnClientEvent:Connect(OnEquippedFrame) --//.OnClientEvent will wait for a signal from the server


Server

local RefreshPetsFrame = game.ReplicatedStorage:FindFirstChild("RefreshPetsEquipped") or Instance.new("RemoteEvent", game.ReplicatedStorage) --//Making the RemoteEvent if it's not already there and sending it to ReplicatedStorage
RefreshPetsFrame.Name = "RefreshPetsEquipped" --//Have to give it the proper name in order for the client to find it
---blablabla
print("Test")
RefreshPetsFrame:Fire()


Hopefully this helps.

0
I have add (player) inside the function and change the Fire with FireClient(player), now work perfectly, ty GuerraReturns 122 — 6mo
0
Ah yes, sorry I forgot to edit that part. Glad I could help. CeramicTile 847 — 6mo