Why does nothing below my task.wait(1) doesn't run

Hello. I was working on this knockback system but then I couldn’t delete the body velocity properly, after adding some print statements nothing below task.wait(1) doesnt seem to work.

the ‘ragdolled, waiting now’ prints but nothing else below it does.

I tried using wait(), but same thing.
I tried

local function Delay(duration)
        local t = os.clock()
       while os.clock() - t <= duration do
		
      end
end

and it just froze my game when it would reach to the Delay(1) line.

2 Likes

Have you tried removing it at all?

Removing the “task.wait(1)” line

oh so u want me to try it without the wait

1 Like

just tried it, prints everything

Does it work or does it just print without actually working

The script is probably destroyed or disabled during the waiting, and therefore the other parts cannot be executed…

1 Like

nope. it wont. there is nothing that disables or deletes

use task.delay() instead of task wait.

it prints everything, but the ragdols and knockback happen so quickly i cant see it. there is a little 0.0001 seconds of freeze though, probably indicating that it happened too quickly

same thing. someone had told me to use that in discord server

Most likely a issue with your script.




local r6Module = require(game:GetService('ServerScriptService').R6Ragdoll.ModuleScript)
local animation = game:GetService('ReplicatedStorage').animation
local stage = 4
local debris = game.Debris

script.Parent.deal.Changed:Connect(function(player)
	
	script.Parent.Touched:Connect(function(hit)
		if hit.Name ~= 'Torso' then
			return
		end
		if hit.Parent.Humanoid and game.Players:GetPlayerFromCharacter(hit.Parent) then
			local char = hit.Parent
			if script.attacker.Value == char.Name then
				print('self attac')
			end
			if char.hitAlready.Value == true then
				return
			end
			char.hitAlready.Value = true
			
			char.Humanoid:TakeDamage(10)
			if stage == 4 then
			
				local kb = Instance.new('BodyVelocity')
				kb.Parent = char.HumanoidRootPart
				kb.MaxForce = Vector3.new(300000,300000, 300000)
				kb.Velocity = game.Workspace[script.attacker.Value].HumanoidRootPart.CFrame.LookVector * 100
				if char.RagdollTrigger then	
					
					char.RagdollTrigger.Value = true
					print('ragdolled, waiting now')
					
					print('waited')
					char.RagdollTrigger.Value = false

				else
					print('no ragdoll trigger')
					r6Module:Setup(char)
					
					r6Module:Unragdoll(char)
				end
				print('no more if statement')
				char.HumanoidRootPart.BodyVelocity:Destroy()
			end
			print('no more')
			if  stage ~= 4 then
				local anim = animation.stages[stage]
				char.Humanoid:LoadAnimation(anim):Play()
				
			end
			
			char.hitAlready.Value = false
		end
	end)
end)

i dont think there is any problems here. i mean it already got to the ragdolled,waiting now. i also start flying while being knocked down towards the direction i was facing… sooo

Where exactly is the script placed?

image
its the script deal. the hitbox is located at replicated storage

do the hitbox (the part) get deleted some sort of?

idk. i already making a remove event instead of this one server script.

update:
it seems to be working so far

Hey. I just realized that i had put a script in the hitbox that would delete itself if it’s parent is changed to workspace. while deleteing the older scripts
This completely slipped my mind as I made it a while ago, and only just decided to work on this projcet with my friend. i will make your answer the solutuon, thanks for taking your time to help me out.

1 Like