Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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!

7 comments

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.

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

1

Please help me instead of picking out the small things wrong, yet I thank you for the pointing out of that possible issue

1

thats a big problem. dont be mean to him just because he suggested a change in your code

0

Locked doesn't do anything other than change if it can be selected using the mouse in studio.

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.

0

pretty sure rthro is just r15 but with scaling

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.