i have 2 local scripts with user input on each one with the dame input how can i control on which scripts fires first when player clicks on the input
Using Task.Wait(), it yields the entire thread (The rest of the code) for a certain amount of time in seconds. If you let it blank, just “Task.Wait()”, it will yield for a single frame. Basically, it waits for a certain amount of time before continuing the code
i think thats not an efficent solution since it still fires after its waiting finishes
Adding on to what @BHUNO545 said, you yield the script for as long as you want. How do you determine if the script is the first? Have an attribute for the script you want to fire first called “ToFireFirst”. Then In both your scripts…
— Input stuff bls bla bla
if not script:GetAttribute(“ToFireFirst”) then return end — Change time to what you want
``
Edit: Stop the function instead if you don’t want it to fire
So, could you be more specific on what you want to achieve, exactly?
like when player clicks on gui for example the gui shows where to place random object on the ground by clicking on the input and another script that has the same input can causes issues with the gui script for example
Did you see my post above, I recommended to stop the input function if it’s the wrong script
You mean clicking on the gui? Or do you mean pressing a key with the gui showing on the screen? I’m confused, if you could clarify it would be nice
but the hacker can simply change the attribute no?
script A: click on gui → clicks on input X → fires an event → rest of the code
script B: clicks on input X → fires an event → rest of the code
problem both of the scripts have the same inputs which are needed to be the same on both scripts but when player clicks on gui and then clicks on the screen 3d world well scriptA and B fires at the same time while i need only script A to be fired here
you use debounce
local debounce=false
function onclick()
if debounce then
return
end
debounce=true
--do someting
debounce=false
end
mouse1click:connect(onclick)
userinputservice.inputbegan:connect(funtion(key)
onclick()
end)
well 1. there are 2 different scripts not 1 anf besides the player can change the value of the debounce by just hacking
Well, then maybe use a corountine thread instead. The hacker can’t change the code, only the instances that he can control (Aka his own character, and any Remote functions he can fire)
he cant change values on a local script?
how would coroutine help here?
He can’t change the code directly, but for example, if there’s a value “Damage” (by value I mean the instance, like String value, number value and etc), and the script using it is a local script, he can change the value “Damage”, and thus affect the local script
How would coroutine help here?
Well, because then the hacker can’t change the value since it is in the code directly, not like an instance. Coroutine also helps because it creates like a second script inside a single script
is there an advanced tutorial about how hacker can hack i ve seen many but they are common sense
And what’s stopping them from changing the value inside the coroutine?
What I meant is that, since coroutine has the “effect” of creating 2 scripts (Or more) inside 1, you could store the value (Number) inside the coroutine, and thus you wouldn’t need a value (Instance). Sorry if it was confusing and I should’ve definitely have phrased it better!