How would i go about can - colliding a character's body parts?
So i am making a ragdoll script, and it looks pretty weird.
you could test this out with a script that i will give you below (make a local script inside of starter character scripts.)
full script:
01 | local plr = game.Players.LocalPlayer |
02 | local char = plr.Character or plr.CharacterAdded:Wait() |
03 | local humanoidRootPart = char:WaitForChild( "HumanoidRootPart" ) |
04 | humanoidRootPart.CanCollide = false |
05 | local humanoid = char:WaitForChild( "Humanoid" ) |
06 | local camera = game.Workspace.CurrentCamera |
07 | local uis = game:GetService( "UserInputService" ) |
09 | local hasRagdolled = false |
11 | uis.InputBegan:Connect( function (input) |
12 | if input.KeyCode = = Enum.KeyCode.R then |
13 | if hasRagdolled = = false then |
15 | for _, v in pairs (char:GetDescendants()) do |
16 | if v:IsA( "Motor6D" ) then |
18 | camera.CameraSubject = humanoidRootPart |
19 | humanoid.PlatformStand = true |
20 | humanoid.WalkSpeed = 0 |
21 | humanoid.JumpPower = 0 |
23 | local a 0 = Instance.new( "Attachment" ) |
26 | local a 1 = Instance.new( "Attachment" ) |
29 | local ballSocketConstrait = Instance.new( "BallSocketConstraint" ) |
30 | ballSocketConstrait.Parent = v.Part 0 |
31 | ballSocketConstrait.Attachment 0 = a 0 |
32 | ballSocketConstrait.Attachment 1 = a 1 |
37 | for _, v in pairs (char:GetChildren()) do |
38 | if v:IsA( "BasePart" ) then |
39 | if v.Name ~ = "HumanoidRootPart" then |
45 | elseif hasRagdolled = = true then |
47 | humanoid.JumpPower = 50 |
48 | humanoid.WalkSpeed = 16 |
49 | humanoid.PlatformStand = false |
50 | for _, v in pairs (char:GetDescendants()) do |
51 | if v:IsA( "BallSocketConstraint" ) then |
52 | camera.CameraSubject = humanoid |
55 | if v:IsA( "Motor6D" ) then |
59 | for _, v in pairs (char:GetChildren()) do |
60 | if v:IsA( "BasePart" ) then |
what i need help with:
1 | local char = game.Players.LocalPlayer.Character |
3 | for _, v in pairs (char:GetChildren()) do |
4 | if v:IsA( "BasePart" ) then |
5 | if v.Name ~ = "HumanoidRootPart" then |
hopefully someone can help me with this.