Why wont this coroutine work?

what I’m trying to do is have the ragdoll function continue to run even when the bleedout function is called. It doesn’t work with or without coroutine. This might seem obvious, but I’m not sure why it won’t work.

no print statement is ran after and the ProximityPrompt is never made.

If it helps this is a module script.

function bleedout(chr, hum)
	wait(6)
	if hum:GetState() == Enum.HumanoidStateType.Ragdoll then
		chr:FindFirstChild("Health").Enabled = false
		repeat
			if hum:GetState() == Enum.HumanoidStateType.Ragdoll then
				wait(3.5)
				hum.Health -= 3.5
			end
		until hum:GetState() ~= Enum.HumanoidStateType.Ragdoll
	end
end

function ragdoll_handler.ragdoll(chr, length, revive, death)
	local plr = game:GetService("Players"):GetPlayerFromCharacter(chr)
	
	local head = chr:FindFirstChild("Head")
	local torso = chr:FindFirstChild("Torso")
	local leftarm = chr:FindFirstChild("Left Arm")
	local rightarm = chr:FindFirstChild("Right Arm")
	local leftleg = chr:FindFirstChild("Left Leg")
	local rightleg = chr:FindFirstChild("Right Leg")
	
	local hum = chr:FindFirstChild("Humanoid")
	ragdollstate_event:FireClient(plr, hum, "ragdoll", revive)
	
	createattachtments(head, torso, leftarm, rightarm, leftleg, rightleg)
	motor6d(torso)
	for _, possibletool in pairs(chr:GetChildren()) do
		if possibletool:IsA("Tool") then
			possibletool.Parent = plr.Backpack
		end
	end
	torso.Parent:FindFirstChild("HumanoidRootPart").CanCollide = false
	if revive == true then
		if death == true then
			coroutine.wrap(bleedout(chr,hum))
			print("hello")
		end
		local revive_prompt = Instance.new("ProximityPrompt", torso)
		revive_prompt.Name = "ReviveProximityPrompt"
		revive_prompt.RequiresLineOfSight = false
		revive_prompt.HoldDuration = 3.55
		revive_prompt.MaxActivationDistance = 4.65
		revive_prompt.ActionText = "Revive "..plr.DisplayName
		revive_prompt.ObjectText = "Current Health "..math.round(hum.Health).."%"
		
		revive_prompt.TriggerEnded:Connect(function()
			motor6d(torso)
			for _, ragdoll_debris in pairs(chr:GetDescendants()) do
				if ragdoll_debris:IsA("BallSocketConstraint") then
					ragdoll_debris.Attachtment0:Destroy()
					ragdoll_debris.Attachtment1:Destroy()
					ragdoll_debris:Destroy()
				end
			end
		end)
	end
end

instead of coroutine.wrap() use coroutine.resume(coroutine.create(function),properties)

1 Like

did not work, doesn’t print or make the prompt

also putting the properties outside of coroutine.create(function) causes an error.

did u use coroutine.resume(coroutine.create(bleedout),chr,hum)

1 Like

ah to be honest, that was my fault I should have known, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.