Ad
Log in to vote
3

Is this the proper way to make your Game BodyType compatible?

Asked by
Ziffixture 6785 Moderation Voter Community Moderator
2 years ago

This is what I read, I made it slightly more efficient though, I'm pretty sure this is how people use it? I've never worked with BodyTypes before, I may be completely wrong, so don't judge, either that or the source I read from is horribly wrong.

I'd also like to know if it's necessary to also include Rthro?

local Player = game:GetService("Players").LocalPlayer
local Character = workspace:WaitForChild(Player.Name)
local Humanoid = Character:FindFirstChild("Humanoid")

local BodyParts = {};
for _,Part in ipairs(Character:GetChildren()) do
   if (Part:IsA("BasePart") and ~= nil) then
      table.insert(BodyParts, Part)
   end;
end;

Player:LoadCharacter()

pcall(function()
    if (Humanoid and Humanoid.RigType == Enum.HumanoidRigType.R15) then
       for i = 1,#BodyParts do
          BodyParts[i].Locked = true
       end;
    end;
end)

pcall(function()
    if (Humanoid and Humanoid.RigType == Enum.HumanoidRigType.R6) then
       for i = 1,#BodyParts do
          BodyParts[i].Locked = true
       end;
    end;
end)

Thanks!

0
Don't use :WaitForChild() on workspace just to get the character. Use the character property of player instead. Imagine if terrain joined your game, they'd break it. User#24403 64 — 2y
2
How does this have anything to do with the question I asked? It doesn’t matter what I do, the only thing you got right was the misunderstanding the Script would make, I can fix that myself Ziffixture 6785 — 2y
1
Please help me instead of picking out the small things wrong, yet I thank you for the pointing out of that possible issue Ziffixture 6785 — 2y
1
thats a big problem. dont be mean to him just because he suggested a change in your code Gey4Jesus69 2704 — 2y
View all comments (3 more)
0
Locked doesn't do anything other than change if it can be selected using the mouse in studio. hiimgoodpack 2009 — 2y
0
Not sure what you want here. If you want to change the player's body then you change your game settings to R6 or whatever. despicablejack2005 83 — 2y
0
pretty sure rthro is just r15 but with scaling brokenVectors 525 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

If I were you, I would avoid trying to use two if statements for two RigTypes, because you don't really want to be accessing the individual limbs of the character most of the time. Either you'd use HumanoidRootPart, or loop through all of the character's children and check if they're a part.

Ad

Answer this question