Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i go about can - colliding a character's body parts?

Asked by
Dexiber 272 Moderation Voter
4 years ago

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:

01local plr = game.Players.LocalPlayer
02local char = plr.Character or plr.CharacterAdded:Wait()
03local humanoidRootPart = char:WaitForChild("HumanoidRootPart")
04humanoidRootPart.CanCollide = false
05local humanoid = char:WaitForChild("Humanoid")
06local camera = game.Workspace.CurrentCamera
07local uis = game:GetService("UserInputService")
08 
09local hasRagdolled = false
10 
11uis.InputBegan:Connect(function(input)
12    if input.KeyCode == Enum.KeyCode.R then
13        if hasRagdolled == false then
14            hasRagdolled = true
15            for _, v in pairs(char:GetDescendants()) do
View all 68 lines...

what i need help with:

1local char = game.Players.LocalPlayer.Character
2 
3for _, v in pairs(char:GetChildren()) do
4        if v:IsA("BasePart") then
5        if v.Name ~= "HumanoidRootPart" then
6            v.CanCollide = true
7        end
8    end
9end

hopefully someone can help me with this.

1 answer

Log in to vote
0
Answered by 4 years ago

Do you have experience with collision groups? you could put them in a collision group and then put them in a different one when you want them to not collide

01local phyicsService = game:GetService('PhysicsService')
02 
03local plr, other = 'Player', 'Other' -- groups
04 
05local setPlr = phyicsService:CreateCollisionGroup(plr)
06local setNpc = phyicsService:CreateCollisionGroup(other)
07 
08phyicsService:CollisionGroupSetCollidable(plr, other, false)
09 
10function addToCollisionGroup(mod, group)
11    for k, v in pairs(mod:GetChildren()) do
12        if v:IsA('BasePart') then
13            phyicsService:SetPartCollisionGroup(v, group)
14        end
15    end
View all 24 lines...

and when you need to change it you can do this:

1phyicsService:CollisionGroupSetCollidable(plr, other, true)

hope this helped!

Ad

Answer this question