Code not registering a Boolean value?

So i’m trying to make a ragdoll script that activates while a boolean value is set to true, here being where the value is located:


The value is created with this script:

local playerRagdoll = char:WaitForChild("Ragdolled") -- Every other variable is defined. I just think that this here might be the problematic one.

		-- Creates the ragdoll value instance
		local playerRagdoll ="BoolValue")
		playerRagdoll.Value = false
		playerRagdoll.Parent = char
		playerRagdoll.Name = "Ragdolled"

And gets activated with this script

local function ragdollThreader()
	while playerRagdoll.Value == true do
		print("In loop") -- Its not even registering :c
		-- Init
		local humanoidRootPart = char:WaitForChild("HumanoidRootPart")
		local humanoid = char:WaitForChild("Humanoid")
		humanoid.BreakJointsOnDeath = false
		humanoid.RequiresNeck = false
		humanoid.PlatformStand = true

		-- Check for joints
		for i, v in pairs(char:GetDescendants()) do
			if v:IsA("Motor6D") then

				-- Create attachments
				local socket ="BallSocketConstraint")
				local a1 ="Attachment")
				local a2 ="Attachment")
				a1.Parent = v.Part0
				a2.Parent = v.Part1
				socket.Parent = v.Parent
				socket.Attachment0 = a1
				socket.Attachment1 = a2
				a1.CFrame = v.C0
				a2.CFrame = v.C1

				-- Set constraints
				socket.LimitsEnabled = true
				socket.TwistLimitsEnabled = true

				v.Enabled = false


		-- Remove ragdolls
		humanoid.PlatformStand = false
		for i, v in pairs(char:GetDescendants()) do
			if v:IsA("BallSocketConstraint") then
			elseif v:IsA("Motor6D") then
				v.Enabled = true

Changing the boolean value doesn’t prove to do anything meaning that the while loop itself might be the problem. Did I do something wrong when referencing the value? I don’t know, I’ve been trying to solve this for the past hour and am still stumped.

try to put the booleam value in the ServerStorge

Instead of using a while loop that never runs since the value is set to false by default. Use GetPropertyChangedSignal.

And do you ever run the function you created?


I’m suspecting they run the function once when the player joins and don’t touch it again afterwards when trying to change the value.

Yes, It is spawned later in the code.

I think this might be the best solution. I’ll try it out and see if it affects anything later.

1 Like

@jaipack17 Tried it, didn’t work.

I know what the error is. The bool value object is not being instanced for some reason. I just can’t seem to find a workaround. Here is the code:

local playerRagdoll = char:FindFirstChildOfClass("BoolValue")

I’ve also tried

local playerRagdoll = char:WaitForChild("Ragdolled")