Bindable Function only firing when I reload the script

So I have been trying to send data from a client script to another one through a bindable function and the bindable function just doesn’t work. I tried to debug but nothing is priting. But it’s only when I reload my script that the bindable function is starting to work which is kind of confusing. Here is my script:

The “Firing” script:

local bfunctions = game.Players.LocalPlayer.Character:WaitForChild("Function")
bfunctions:Invoke("SetM1s",selected.Name)

The “Fired” script:

local bfunctions = game.Players.LocalPlayer.Character:WaitForChild("Function")
bfunctions.OnInvoke = function(state,o)
	print("fired")
	if state == "SetM1s" then
		M1s = {
			animator:LoadAnimation(shootAnimsF.M1s[o]:WaitForChild("Punch1")),
			animator:LoadAnimation(shootAnimsF.M1s[o]:WaitForChild("Punch2")),
			animator:LoadAnimation(shootAnimsF.M1s[o]:WaitForChild("Punch3")),
			animator:LoadAnimation(shootAnimsF.M1s[o]:WaitForChild("Punch4")),
		}
		RollingAnims = {
			["Forwards"] = animator:LoadAnimation(shootAnimsF.Rolling[o]:WaitForChild("FRoll")),
			["Right"] = animator:LoadAnimation(shootAnimsF.Rolling[o]:WaitForChild("RRoll")),
			["Left"] = animator:LoadAnimation(shootAnimsF.Rolling[o]:WaitForChild("LRoll")),
			["Backwards"] = animator:LoadAnimation(shootAnimsF.Rolling[o]:WaitForChild("BRoll")),
			["RollJump"] = animator:LoadAnimation(shootAnimsF.Rolling[o]:WaitForChild("RollJump")),
			["AirRollTouch"] = animator:LoadAnimation(shootAnimsF.Rolling[o]:WaitForChild("AirRollTouch")),
			["RollTouch"] = animator:LoadAnimation(shootAnimsF.Rolling[o]:WaitForChild("OnRollTouch")),
			["RollAttack"] = animator:LoadAnimation(shootAnimsF.Rolling[o].RollAttack),
		}
		SkyJumpAnims = {
			["Forwards"] = animator:LoadAnimation(skyjumps[o].SkyJumpForwards),
			["Right"] = animator:LoadAnimation(skyjumps[o].SkyJumpRight),
			["Left"] = animator:LoadAnimation(skyjumps[o].SkyJumpLeft),
			["Backwards"] = animator:LoadAnimation(skyjumps[o].SkyJumpBack),
			["Nil"] = animator:LoadAnimation(skyjumps[o].SkyJumpNone)
		}
		SpecialsAnims = {
			AttackCounter = animator:LoadAnimation(shootAnimsF.Specials[o].AttackCounter),
			CounterAttackHit = animator:LoadAnimation(shootAnimsF.Specials[o].CounterAttackHit),
		}
	end
end

If anyone have any so solution to this problem please help!
(also it was working perfectly fine yesterday and i haven’t touched to anything)

2 Likes

I thiiiink this is the issue:
The invoking script runs before the listener-setup script, so the latter misses the invocation. Try adding wait() before :Invoke

That’s not a good solution, it’s just to illustrate what goes wrong. A proper solution would be to manage the order that scripts run in properly, or writing code that doesn’t depend on the order that scripts run in.

2 Likes

I have tried to add a wait() before the the Bindable Function Invoke but it seems to be the same problem: nothing is sending. And I also noticed that it’s the same for others scripts that are being fired by this Bindable Function, even if I add a little delay before firing. I think I should probably do disable then enable the script ? I tried it and it works but the problem is if more scripts had to be fired through this function, I would have to disable them then enable them so theyworks. And I also forgot to mention that the “Firing” script is invoking others through a TextButton and this why I don’t understand the problem.

I changed the Bindable Function to a Bindable Event and it’s working. I don’t understand.