How to make the player able to walk through the car
Just edit the CanCollide
property of parts in the car.
for i, v in ipairs(carModel:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.CanCollide = false
end
end
You can use CollisionGroups to make players not collide with the car, while the car can still collide with other parts.
-
Head to the Model tab > Advanced > CollisionGroups Editor
-
Create two collision groups, one for cars and one for players. Untick “Players” to toggle collisions between them.
-
Now you’ll need some scripting skills to assign the cars and players to these collision groups.
You can use the Player.CharacterAdded() event and loop through the parts in the character to assign each one (put in server script):
game.Players.PlayerAdded:Connect(function(player) --player joins the game
player.CharacterAdded:Connect(function(character) --player's character spawns in
for i,part in character:GetChildren() do --loop through all the parts in the character
if part:IsA("BasePart") then
part.CollisionGroup = "Players" --set the collision group
end
end
end)
end)
- Assign all the parts of the car to the Cars collision group. You can do this the same way, with a loop, or set them manually in the properties.
This will allow players’ characters to walk through the car, while the car can still collide with other parts so it doesn’t fall through the floor or drive through buildings.
I think it should work, I’ll definitely try it later, thanks
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.