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.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
-- Creates the ragdoll value instance
local playerRagdoll = Instance.new("BoolValue")
playerRagdoll.Value = false
playerRagdoll.Parent = char
playerRagdoll.Name = "Ragdolled"
end)
end)
And gets activated with this script
local function ragdollThreader()
while playerRagdoll.Value == true do
print("In loop") -- Its not even registering :c
wait()
-- 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 = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("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
end
end
wait(2)
-- Remove ragdolls
humanoid.PlatformStand = false
for i, v in pairs(char:GetDescendants()) do
if v:IsA("BallSocketConstraint") then
v:Destroy()
elseif v:IsA("Motor6D") then
v.Enabled = true
end
end
end
end
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.