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.
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.
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
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
(and btw, the game actually is almost done, combat is really one of the last things we’re working on)