Hye, this is my first post, so I’m not so sure if it is the right category. Anyways, I’m making a game and I want the players to stack so they can make like a “human” tower. I saw some posts saying that the players arms and legs are cancollide false, and I’ve tried making a tower with four players and is pretty difficult to stack, since the arms are cancollide false.
I don’t know if its going to need a script or just a change on the settings, but my question is, is there a way to set players arms to cancollide true? I’m pretty new to scripting, so give me a not too complicated answer if possible.
This should, be in the #development-support:scripting-support
I’m not sure if there will be any problems with physics by doing this, but a simple thing you can do is modify the arms in join.
Connect a callback to the players.PlayerAdded
event.
This should receive the player as an argument.
So, now we can connect an event to the character added function to the player. So, well end up with something like this:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
— We’ll add more here later
end)
end)
Now, you can cycle through the parts which make up the arms.
This is where I need some more info. Is your game set to use the R6 or R15 style rig?
I’m going to try this out when I’m on my laptop. My game is going to be on R6.
If it’s R6 this makes things a lot easier.
You need to simply set:
char.LeftArm.CanCollide = true
And
char.RightArm.CanCollide = true
The names of the arms of R6 have spaces, so char["Left Arm"]
instead of char.LeftArm
.
It is possible to do this, unfortunately it isn’t as easy as setting it initially and then being done with it. It requires being constantly updated bound to RunService.Stepped
as this is fired just after humanoid changes and just before physics calculations.
Setting it just once allows for the humanoid changes to revert it, so instead it must be done each frame. Setting the legs to CanCollide true seems to give rather odd elastic collision behaviour so I’d avoid changing legs as they collide just fine as they are, ignoring animations when calculating collisions.
This will need to be done on the client, I’d recommend putting this local script inside StarterPlayer.StarterCharacterScripts
:
local parts = {}
for _, child in pairs(script.Parent:GetChildren()) do
if child:IsA("BasePart") and string.find(child.Name, "Arm") then
table.insert(parts, child)
end
end
game:GetService("RunService").Stepped:Connect(function()
for _, part in pairs(parts) do
part.CanCollide = true
end
end)
The problem with this approach is that the animations will affect collisions, so you may want to consider not altering the CanCollide property of the arms and instead weld some invisible, CanCollide true parts where the arms are situated when idle.
Thank you for the help, I apreciate it.
I will try this after.
The collision of the limbs of Humanoids are automatically false. The collision of the Head and the HumanoidRootPart are automatically true and are set to that every frame.
Yes, it is possible to set the CanCollide property for limbs. Just a note though - don’t do that for HumanoidRootParts. Those are used for physics calculations and keeping the humanoid above ground. If you need to change collisions for those, take a look at CollisionGroups.
Is there a way to make the legs collide aswell?
same script, but you replace “Arm” with “Leg”