Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change the CollisionGroupId on a player?

Asked by
uhTeddy 101
6 years ago

I am working on a project were I need to change the collision group ID. I tried two ways in my scripts but neither are working please help.

game.Players.PlayerAdded:connect(function(player)
    local character = workspace:FindFirstChild(player.Name)
    for i,v in pairs(character:GetChildren()) do
        if v.ClassName == "MeshPart" then
            wait(.01)
            v.CollisionGroupId = 2
        end
    end
end)

and

game.Players.PlayerAdded:connect(function(player)
    for i,v in pairs(player.Character:GetChildren()) do
        if v.ClassName == "MeshPart" then
            wait(.01)
            v.CollisionGroupId = 2
        end
    end
end)
0
Read this wiki article about and how to use CollisionGroupId: http://wiki.roblox.com/index.php?title=Collision_Filtering . Also, when you want to access the Player's Character, you would do player.Character, not find their name in the workspace, as there might be another instance of the same name. UgOsMiLy 1074 — 6y
0
I used a collision group plugin where all I need to do is change the value of the collision group. When I changed it manually In game it worked though through the script it doesn’t uhTeddy 101 — 6y
0
I used a collision group plugin where all I need to do is change the value of the collision group. When I changed it manually In game it worked though through the script it doesn’t uhTeddy 101 — 6y

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
6 years ago

Here's an example what i use to remove Player Collision.

--Get the service
local PS = game:GetService("PhysicsService")

--Create group
PS:CreateCollisionGroup("Characters")

--Set collidability with eachother to false.
PS:CollisionGroupSetCollidable("Characters","Characters",false)

--PlayerAdded
game.Players.PlayerAdded:Connect(function(Player)
    --CharacterAdded
    Player.CharacterAdded:Connect(function(Char)
        wait() -- roblox logic
        --Get all the parts in the character
        for _,v in pairs(Char:GetChildren()) do
            if v:IsA("BasePart") then
                --Add the part to the group so it doesnt collide with eachother.
                PS:SetPartCollisionGroup(v,"Characters")
            end
        end
    end)
end)
0
I would use that except I just need to change the collisiongroupid number uhTeddy 101 — 6y
0
well then on line 19 just do v.CollisionGroupId = int RubenKan 3615 — 6y
0
I tried that and it didn't work uhTeddy 101 — 6y
0
i personaly don't set the ID of a part, but use the pure script sided PhysicsService, so i can't help you with using the property method you're using. RubenKan 3615 — 6y
Ad

Answer this question