A local script in Starter Player > Starter Player Scripts.
Stack Line:
Stack Begin - Studio 17:54:16.250 Script 'Players.poppyloverb.PlayerScripts.LocalScript', Line 3 - Studio - LocalScript:3 17:54:16.251 Stack End
Code:
local player = game.Players.LocalPlayer.Character for i,v in pairs(player:GetChildren()) do if v:IsA("MeshPart") then v.CanCollide = false end end
Please help me!
You actually can't set characters' body parts to be CanCollide false except for limbs. You need to use collision groups.
The first thing you'll want to do is set up a collision group like this. Make sure the box for "Player" is unchecked.
Now, the thing about this is that if you do this from a LocalScript, it will not work because your player will be non-CanCollide only on their own client, but to everyone else's they'll be the default collision group. This is why you'll want to use a PlayerAdded event from a server-side script in ServerScriptService.
local PhysicsService = game:GetService("PhysicsService") game.Players.PlayerAdded:Connect(function(player) -- Fires when the player joins player.CharacterAdded:Connect(function(character) -- Fires when their character is loaded for i,v in pairs(character:GetDescendants()) do -- Use GetDescendants() for accessory handles, etc if v:IsA("BasePart") then -- Not just MeshParts, we want all types of parts. PhysicsService:SetPartCollisionGroup(v, "Player") -- "Player" is the name of the collision group end end end) end)
If you playtest, you'll notice that players will completely walk through each other. I hope this helps! Reply if you have any questions.
The character may not have loaded when the script runs. I recommend moving the script into StarterCharacterScripts.