Can ROBLOX make it easier for us to halt a function?

You’re requesting for Roblox to change something. Therefore, this should be a feature request.

Imagine you aren’t using if statements. In an ideal world, how would you stop the function as it’s running?

Also

I could make this script possibly disgusting looking and laggy,

and

This is not just “muh script isnt nice looking!” it’s just inefficient coding.

How are you going to make the script “inefficient” and “laggy”? If statements aren’t “inefficient.” I’d argue making threads and then stopping them is worse for performance than using a bunch of if statements.

If you really need to stop the threads, your best bet is disabling a script with the code, which doesn’t have to be as painful as you think. You can easily set up a framework for it and make it scalable. Otherwise, you don’t have the ability to stop threads the way you describe.

You might have to sacrifice efficient coding if you want your game to actually function. If the lack of efficiency actually causes problems with performance, then you should go back and try to fix it.

3 Likes

I can’t fix it. Because this is unfixable as ROBLOX doesen’t support this. They’d rather I have waits yielding my script all over the place, waiting for nothing to happen because of if statements about to tell the script nothing should happen.

If you know that this is not achievable the way you want

then it should be in feature requests like @grilme99 said.

I had hoped there would yet be a solution on here. But the lack of what I’m looking for and discussion of me not supposed to be doing this has seemingly convinced me otherwise. Wish there was support for this though

Have you noticed that all the other games that use the same sword mechanics don’t have this issue? Thats because forcing a function to stop isn’t the right way to go about doing it.

Roblox tends to avoid doing changes to already built-in Lua systems, and if they do make those changes, it’d be for a much bigger reason than this. It isn’t Roblox’s fault, think about how much money it will cost them. Roblox Developers could be working on far bigger features than this.

4 Likes

Of course I have noticed it, thought about it, and realized what they’re doing. Most of them just lets their functions complete which is inefficient. Most of them don’t have too much advanced mechanics going on

How do you know that’s what they do? Let’s take Vesteria for example (first game I thought of). They have some really advanced mechanics and pretty good performance. That’s because you shouldn’t be ending a function mid way through.

2 Likes
function()
    print("START")
    wait(4)
    print("MIDDLE")
    wait(3)
    print("END")
end

Then you think this should be this?

function()
    print("START")
    wait(4)
    if shouldBeRunning == true then
        print("MIDDLE")
        wait(3)
        if shouldBeRunning == true then
            print("END")
        end
    end
end

There’s gonna be scopes inside scopes inside scopes depending on how many waits you have and hopefully not having the wait yield the script for too long so it won’t wait a long time on code which won’t run

I don’t know what the best method to do it is because I’ve never done it before. But there is obviously a reason Roblox doesn’t let you easily destroy a thread, because you shouldn’t need to. Look at other methods!

1 Like

The example I posted seems bad, but it’s gonna get worse as the scripts gets longer and more advanced than just printing. I don’t see how stopping the thread is in any capacity bad. I definitely don’t see how it’s worse than this. All I would have to do with such a function, is group the coroutines that requires stopping together, stop them whenever I make an intervention, and then do what I want. No need to worry about code continuing for unwanted reasons, and everything is kept orderly and logical.

Then submit the feature request, but I can almost guarantee you it probably won’t happen for the reasons I mentioned earlier.

“tends to avoid doing changes to already built-in Lua systems” I mean this is false.This is a big enough reason aswell though I feel, it’s really useful and they use it themselves to a degree, just not a way for us to simply use it cause they didn’t implement it. Perhaps it’ll cost them money aswell, but they’re on a mission to power imagination and so far been investing money on stuff which was probably viewed as useful as this. I’ll submit the request later I guess.

Okay, but as far as I’m aware, this hasn’t been requested before. For Roblox to seriously consider assigning a developer to make this, you need to have other people who would also like the change. It’s not just assigning developers Roblox has to worry about. They have to assign and create entire teams for each project. They need someone to oversee the project, the need developer(s), tester(s), etc. This all costs a lot for something that hasn’t been requested before.

Hopefully one day they can manage to do it then.

1 Like

Your implementation is broke by design. This is easily attainable even with Roblox. Just change your perspective. You don’t need to stop the function. You simply need to stop processing whatever you are processing within that function. You have all the power in the world with your code. But if you don’t design a well thought out system then of course the system won’t work as you want it to.

9 Likes

Then do enlighten me. What I am suggesting is well thought out.

I supplied an example in the original post.

And as I repeat myself, your implementation is broken by design. You basically asked for a finite state machine and then said you can’t make a finite state machine.

Within seconds of reading this post I was able to come up with several solutions. In fact several solutions exist within this thread, and you get defensive and stop listening to people. Which is why I suggested a change of perspective.

1 Like

I have been open to these solutions, have tried them, and discarded them as it is either inefficient or not a solution. You talk about having thought of multiple solutions. I invite you to enlighten me with these solutions, surely there is no harm in that? This means post specific script examples. Prove me wrong, if it is all the same, then I have already countered the reasons as to why it is not optimal. You confuse “stop listening to people” with “not very interested in what you’re not looking for”.