-- Lay Down Ragdoll — LocalScript in StarterPlayer > StarterPlayerScripts -- Full script. Works on mobile (published game). Client-side. local Players = game:GetService("Players") local player = Players.LocalPlayer ------------------------------------------------------------ -- GUI (top-right, safe on mobile) ------------------------------------------------------------ local gui = Instance.new("ScreenGui") gui.Name = "RagdollButton" gui.ResetOnSpawn = false gui.IgnoreGuiInset = true gui.Parent = player:WaitForChild("PlayerGui") local btn = Instance.new("TextButton") btn.Size = UDim2.fromOffset(90, 90) btn.Position = UDim2.new(1, -110, 0, 120) btn.BackgroundColor3 = Color3.fromRGB(40, 45, 70) btn.BorderSizePixel = 0 btn.Font = Enum.Font.GothamBlack btn.TextSize = 12 btn.TextColor3 = Color3.new(1, 1, 1) btn.Text = "LAY\nDOWN" btn.AutoButtonColor = false btn.Active = true btn.Parent = gui Instance.new("UICorner", btn).CornerRadius = UDim.new(0.5, 0) local stroke = Instance.new("UIStroke", btn) stroke.Color = Color3.fromRGB(90, 120, 255) stroke.Thickness = 1.5 ------------------------------------------------------------ -- STATE ------------------------------------------------------------ local isRagdolled = false ------------------------------------------------------------ -- RAGDOLL ON ------------------------------------------------------------ local function ragdollOn(char) local hum = char:FindFirstChildOfClass("Humanoid") local hrp = char:FindFirstChild("HumanoidRootPart") if not hum or not hrp then return end hum.PlatformStand = true for _, m in ipairs(char:GetDescendants()) do if m:IsA("Motor6D") and m.Part0 and m.Part1 then local a0 = Instance.new("Attachment") a0.Name = "RagA0"; a0.CFrame = m.C0; a0.Parent = m.Part0 local a1 = Instance.new("Attachment") a1.Name = "RagA1"; a1.CFrame = m.C1; a1.Parent = m.Part1 local socket = Instance.new("BallSocketConstraint") socket.Attachment0 = a0 socket.Attachment1 = a1 socket.LimitsEnabled = true socket.UpperAngle = 35 socket.TwistLimitsEnabled = true socket.TwistLowerAngle = -35 socket.TwistUpperAngle = 35 socket.Parent = m.Part0 m.Enabled = false end end task.defer(function() if not hrp.Parent then return end -- Small upward bump so feet leave the ground hrp.AssemblyLinearVelocity = Vector3.new(0, 6, 0) -- Rotate around RIGHT axis = fall BACKWARD. -- (LookVector was the cartwheel bug.) hrp.AssemblyAngularVelocity = hrp.CFrame.RightVector * 5 end) print("[Ragdoll] ON") end ------------------------------------------------------------ -- RAGDOLL OFF ------------------------------------------------------------ local function ragdollOff(char) local hum = char:FindFirstChildOfClass("Humanoid") if not hum then return end for _, m in ipairs(char:GetDescendants()) do if m:IsA("Motor6D") then m.Enabled = true end end for _, c in ipairs(char:GetDescendants()) do if c:IsA("BallSocketConstraint") then c:Destroy() end end for _, a in ipairs(char:GetDescendants()) do if a:IsA("Attachment") and (a.Name == "RagA0" or a.Name == "RagA1") then a:Destroy() end end local hrp = char:FindFirstChild("HumanoidRootPart") if hrp then hrp.AssemblyAngularVelocity = Vector3.zero hrp.AssemblyLinearVelocity = Vector3.zero end hum.PlatformStand = false hum:ChangeState(Enum.HumanoidStateType.GettingUp) print("[Ragdoll] OFF") end ------------------------------------------------------------ -- BUTTON ------------------------------------------------------------ btn.MouseButton1Click:Connect(function() local char = player.Character if not char then warn("[Ragdoll] No character yet") return end isRagdolled = not isRagdolled if isRagdolled then ragdollOn(char) btn.Text = "STAND\nUP" btn.BackgroundColor3 = Color3.fromRGB(180, 55, 55) stroke.Color = Color3.fromRGB(255, 120, 120) else ragdollOff(char) btn.Text = "LAY\nDOWN" btn.BackgroundColor3 = Color3.fromRGB(40, 45, 70) stroke.Color = Color3.fromRGB(90, 120, 255) end end) ------------------------------------------------------------ -- RESPAWN RESET ------------------------------------------------------------ player.CharacterAdded:Connect(function() isRagdolled = false btn.Text = "LAY\nDOWN" btn.BackgroundColor3 = Color3.fromRGB(40, 45, 70) stroke.Color = Color3.fromRGB(90, 120, 255) end)