BindableEvent Dilemna

I have multiple combat styles in my game, and you can equip them with hot bar slots. Each style is a different script, and when you equip a different one, it disables everything and then enables the one that you’re using. I’m trying to fix a glitch where you can spam switch from one style to another, so I have a variable in each that is what style is currently being used. I’m using a bindable event to communicate between scripts and change the variables. The problem is, as mentioned before, every script except the one in use is disabled, and therefore, they cannot receive the bindable event when it’s fired and change their variable.


each style and ability has its own script, the four styles are default, boxing, sumo, and muay thai
How I’m trying to communicate:

StyleChange:Fire("Boxing")

and then the other three would receive it like this:

StyleChange.Event:Connect(function(S)
	Style = S
end)

when you try to punch this is one of the conditions it goes through:

if Style ~= nil and Style ~= "Boxing" then return end

but again, scripts can’t do the second one, reception, because they’re disabled. If anyone has any ideas on how to fix this I would appreciate it!

Hey there,

what if you enable all of them and instead give them internal state of being disabled / enabled,
each of the modules would have a variable something like Style.Enabled and a function

function Style:Enable(b)
   self.Enabled = b
end

You would then use that variable to check whether the style is being used or not.
In your controller, you would cache the current style being used and once a new one is equipped disable old one and enable new one, something like this:

--currentStyle = the one being used currently

currentStyle:Enable(false)
currentStyle = newStyle --the style that you want to equip
currentStyle:Enable(true)

I thought about that, but the game’s almost ready to launch which means making a change to the code that big would be very glitchy as everything is intertwined and works together. I’m trying to find a better way to do it than that. I thought about using a StringValue, but for some reason the doesn’t replicate to the other scripts when changed by one? thanks for helping!

To be honest, I would rather go with the change, it will benefit in the longer run as well since you can count on each style having that method. Also I don’t see how this change would be big enough to cause troubles, it’s just switching from checking whether the ModuleScript is disabled or a variable is disabled.

Alright, I’ll try that. Thanks! :+1:

1 Like

Can’t you just wrap up all the abilities in a module?

1 Like

The game isn’t ‘almost ready’ to launch at all then. Sougood’s method is your best bet and if you stick to your method with some hacky workarounds, it’ll be 1000x worse for you in the long run

Bro, Why can’t you wrap up the abilities in the module instead of making a folder with millions of local scripts

1 Like

alright alright yall I said I’m rewriting to go with sougood’s method, you don’t have to repeat what he said a million times. Thanks for trying to help though :slight_smile:
(and btw, the game actually is almost done, combat is really one of the last things we’re working on)