You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I’m trying to make it so if Script A plays, it doesn’t cancel Script B (They both have the same intention/task of disabling the enemy’s backpack/toolbar), sorry if it’s confusing, it’s kind-of difficult to explain.
What is the issue? Include screenshots / videos if possible!
Script A cancels-out Script B if they both simultaneously play.
Script A Cancelling Script B (The Duration of the Tool Bar being Disabled is Significantly Shorter
Script B Behaving Correctly w/o Cancelling (The Tool Bar stays Disabled for the Correct Amount of Time
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried to look if someone had a similar problem, however I couldn’t find anything. I’m sure someone has likely been in the same scenario, I likely just can’t word it correctly.
Code: A
local EnemyScript = script.DisableEnemysToolbar:Clone()
EnemyScript.Parent = enemyHum
EnemyScript.Enabled = true
Code B:
local EnemyScript = script.DisableEnemysToolbar:Clone()
EnemyScript.Parent = enemyhum
EnemyScript.Enabled = true
Code C:(the script both A, and C, are referring to)
I would recommend placing the function that disables the toolbar inside of a module, and require the module in both Script A and B. This would allow you to add a debounce to the function that temporarily prevents it from activating again if another script already did
Thanks for the suggestion, shortly after adding the module, I noticed an error “StarterGui:SetCoreGuiEnabled must be called from a local script.”. I guess this means I can’t use a module for this task, unfortunately.
That’s impossible, as if you code that function as a module function and run the function on a local script it shall never error like that. May you please elaborate and show me your module script, and how you require&use it?
Well, that’s unfortunate, do you think there could be another work-around code I can insert into my scripts that will disable the victim from using their toolbar, other than disabling their CoreGui entirely? Like for example I’m using a bool value to disable them from being able to punch during the animation, but when I used that same method to disable their toolbar the same problem arose.
You could use a remote event, fire it on the server, and when the client receives the remote have it check if the toolbar is already disabled (bool value) and if so then return, and if not then set the toolbar to disabled and mark the disabled bool value as true
After about an hour, I finally figured it out. I liked your thought of checking if the toolbar is already disabled or enabled through another bool value and it gave me an idea, so I took your advice, except rather than using a remote event I simply checked if the value was true or not and added the necessary events to ensure the backpack got disabled whenever it was required. Thanks a lot!