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
-
Open Roblox Studio and select your car model.
-
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. -
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
-
Select all the parts in your car model.
-
In the Properties window, set their
CollisionGroup
to Car.
This is the part of the Properties window where you assign the Collision Group.
Step 3: Script to Handle Player Collision Grouping
-
In ServerScriptService, create a new script (name it anything you like).
-
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!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.