Cars AntiCollide

Hello, I would like to know how I can make an anti-collision for the vehicles in my game, so that they do not collide with the player. I have been watching a couple of tutorials but none of them work, Thanks.

Hey there! It sounds like you’re trying to prevent cars from colliding with players, and you can definitely do this using Collision Groups in Roblox Studio. Here’s a step-by-step guide to help you out:

Step 1: Set Up Collision Groups

  1. Open Roblox Studio and select your car model.

  2. Go to the MODEL tab, then click on Collision Groups.

    Make sure that you have the checkbox setup like in the image or it will not work!!!


    This is what the Collision Groups button looks like.

  3. In the window that opens, create two new groups:

    • Car: This group will be assigned to all the parts of your car.
    • Player: This will be for player characters.

Step 2: Assign Collision Groups to Car Parts

Step 3: Script to Handle Player Collision Grouping

  1. In ServerScriptService, create a new script (name it anything you like).

  2. Add this code to automatically set players’ collision groups when they spawn:

    local Players = game:GetService("Players")
    
    Players.PlayerAdded:Connect(function(Player)
        Player.CharacterAdded:Connect(function(Character)
            for _, BasePart in pairs(Character:GetDescendants()) do
                if BasePart:IsA("BasePart") then
                    BasePart.CollisionGroup = "Player"
                end
            end)
        end)
    end)
    

Step 4: Test Your Setup

After setting up the collision groups and adding the script, cars and players should no longer collide. This will ensure smoother interactions in your game!

2 Likes

It worked for me at first, but now I get an error about something exceeding something, any solution you know of?
It says “Encountered 100 clamping events of physical properties. No further warnings will be reported.”