[SOLVED] Make a part not collide with players using physics service?
Asked by
4 years ago Edited 4 years ago
Imagine this scenario: I'm trying to make a part that players can walk through but it has to unanchored, if I just set can collide to false it falls to the void. I then learned that I can use the PhysicsService service to make a collision group between the players and the part. Only issue is I cant get it working. Anyone know how I can do that?
Current code:
01 | local PhysicsService = game:GetService( "PhysicsService" ) |
02 | local Players = game:GetService( "Players" ) |
03 | PhysicsService:CreateCollisionGroup( "Parts" ) |
04 | PhysicsService:CreateCollisionGroup( "Players" ) |
05 | PhysicsService:CollisionGroupSetCollidable( "Parts" , "Players" , false ) |
07 | game.Workspace.ChildAdded:Connect( function (c) |
09 | if c.Name = = "Hoverboard" then |
11 | local Collision = c:WaitForChild( "Collision" ) |
12 | PhysicsService:SetPartCollisionGroup(Collision, "Parts" ) |
18 | Players.PlayerAdded:Connect( function (p) |
20 | p.CharacterAdded:Connect( function (c) |
22 | for i,v in pairs (c:GetChildren()) do |
24 | if v:IsA( "Part" ) or v:IsA( "MeshPart" ) then |
26 | PhysicsService:SetPartCollisionGroup(v, "Players" ) |
The code is supposed making it so that part that is making the Hoverboard 'float' cannot collide with players but Its not working.