I thought I wanted to try cleaning up my script.
local motorjoints = {
"Neck",
"LeftAnkle",
"RightAnkle",
"LeftWrist",
"RightWrist",
"LeftElbow",
"RightElbow",
"LeftShoulder",
"RightShoulder",
"LeftKnee",
"RightKnee",
"LeftHip",
"RightHip",
"Waist",
"Root",
}
game.ReplicatedStorage:WaitForChild("ToggleEvent").OnServerEvent:Connect(function(player,toggle)
local character = player.Character
game.ReplicatedStorage.Players[character.Name]:WaitForChild("Ragdoll").Value = toggle
if toggle == true then
character:WaitForChild("HumanoidRootPart").CanCollide = false
for _, part in pairs(character:GetChildren()) do
if part:IsA("BasePart") then
local motor = part:FindFirstChildOfClass("Motor6D")
if motor then
motor.Parent = game.ReplicatedStorage.Players[character.Name]
end
end
end
print(player.Name..": Toggled.")
elseif toggle == false then
if character:FindFirstChild("HumanoidRootPart") then
character:WaitForChild("HumanoidRootPart").CanCollide = true
local motors = game.ReplicatedStorage.Players[character.Name]
for i,v in ipairs(motorjoints) do
if motors:FindFirstChild(v) then
print(v)
--Neck motor to Head, Waist motor to UpperTorso, etc.
end
end
--[[
if motors:FindFirstChild("Neck") then
motors.Neck.Parent = character:WaitForChild("Head")
end
if motors:FindFirstChild("LeftAnkle") then
motors.LeftAnkle.Parent = character:WaitForChild("LeftFoot")
end
if motors:FindFirstChild("RightAnkle") then
motors.RightAnkle.Parent = character:WaitForChild("RightFoot")
end
if motors:FindFirstChild("LeftWrist") then
motors.LeftWrist.Parent = character:WaitForChild("LeftHand")
end
if motors:FindFirstChild("RightWrist") then
motors.RightWrist.Parent = character:WaitForChild("RightHand")
end
if motors:FindFirstChild("LeftElbow") then
motors.LeftElbow.Parent = character:WaitForChild("LeftLowerArm")
end
if motors:FindFirstChild("RightElbow") then
motors.RightElbow.Parent = character:WaitForChild("RightLowerArm")
end
if motors:FindFirstChild("LeftShoulder") then
motors.LeftShoulder.Parent = character:WaitForChild("LeftUpperArm")
end
if motors:FindFirstChild("RightShoulder") then
motors.RightShoulder.Parent = character:WaitForChild("RightUpperArm")
end
if motors:FindFirstChild("LeftKnee") then
motors.LeftKnee.Parent = character:WaitForChild("LeftLowerLeg")
end
if motors:FindFirstChild("RightKnee") then
motors.RightKnee.Parent = character:WaitForChild("RightLowerLeg")
end
if motors:FindFirstChild("LeftHip") then
motors.LeftHip.Parent = character:WaitForChild("LeftUpperLeg")
end
if motors:FindFirstChild("RightHip") then
motors.RightHip.Parent = character:WaitForChild("RightUpperLeg")
end
if motors:FindFirstChild("Waist") then
motors.Waist.Parent = character:WaitForChild("UpperTorso")
end
if motors:FindFirstChild("Root") then
motors.Root.Parent = character:WaitForChild("LowerTorso")
end
--]]
end
print(player.Name..": Untoggled.")
end
end)
I am really stumped. I wanted the Motor6Ds to get back to their parts. How would I do so?
