Help on "No Stop Obby" script for Adonis

I’ve been working on a “no stop obby” kinda script for a game where if you stop moving for a certain amount of time you will die, but ported into adonis. With this, the owner will be able to change the timer started when someone stops moving to whatever number they want.

I came up with a script that seemed to be working, but had a huge flaw. This is it below:

        Function = function(plr,args)    -- Function to run for command
            local Character = plr.Character
            local Humanoid = Character:FindFirstChild("Humanoid")
            
            while wait(args[2]) do
                if Humanoid.MoveDirection.Magnitude == 0 then
                    Humanoid.Health = 0
                end
            end
        end

Keep in mind that “args[1]” (which im not sure if I need to use for this script} are the players mentioned in the command and “args[2]” is the amount of time they have before they die if they stop moving.

While the script technically does work, the big issue is that it checks every x seconds regardless of if you’re moving or not. This means that if the timer was set to 1 second and you stopped at the last tenth of that second, you would almost instantly die instead of having that 1 second timer.

I’ve tried a different method for this that seems like it would work but doesn’t. I’m assuming the reason it doesn’t is because im treating the argument like a variable when I don’t think it actually is, but correct me if I’m wrong. Here is the code for this method:

		Function = function(plr,args)    -- Function to run for command
			local Character = plr.Character
			local Humanoid = Character:FindFirstChild("Humanoid")
			
			
			if(Humanoid.MoveDirection.Magnitude > 0) then
				args[2] = args[2]
			elseif(Humanoid.MoveDirection.Magnitude == 0) then
				args[2] = args[2] - 0.0166666667
			end
			
			if(args[2] <= 0) then
				Humanoid.Health = 0
			end
		end

What I thought this would do was keep args[2] to whatever amount it was set to if you were moving, and then minus it by 1 second every 60 frames when you weren’t. Even if this method were to work, I’m not really sure if I’d like it anyways since it was more of a rushed idea and will easily break for anyone that uses more than 60 fps (which a lot of obbyists do).

If anyone could add on either one of these scripts and make them work properly, that would be greatly appreciated!

2 Likes