Disable Cancollide of player when seated

Hello,

I am trying to make a script where when the player sits in a seat, the collision will be off,
I am trying to make where vehicles can go thru each other, but it gets stuck when it gets to the player.

I have tried a script, but it does not work, anyone have any idea how to make a script when the player is seated the collision will be off so that other vehicles can go thru it.

You’ll need to use PhysicsService

you can make a collisiongroup for vehicles and that collision grouyp doesn’t collide with itself

Can you send the script?



You could try detecting a state change in the Humanoid, and assigning a collision group to all the parts in the character. You could also assign to the vehicle, but you’d probably want vehicles to collide with each other?

local char = Player.Character or Player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

local tempCharacterCollisionGroup = "temp"

local function onStateChanged(old: Enum.HumanoidStateType, new: Enum.HumanoidStateType): nil
    if new == Enum.HumanoidStateType.Seated then --player sat down
        for _, part in next, char:GetDescendants(), nil do
            if part:IsA("BasePart") then
                part.CollisionGroup = tempCharacterCollisionGroup
            end
        end
    else
        for _, part in next, char:GetDescendants(), nil do
            if part:IsA("BasePart") then
                part.CollisionGroup = "Default"
            end
        end
    end
end

hum.StateChanged:Connect(onStateChanged)

You can loop through all the players characters parts and disable CanCollide

Yes i already have that, but my vehicle stops when it gets at the body of the caracter, and i need the caracter to be able to get on the vehicle because it is high.

I fixed this by using this idea, only i didnt disable cancollide but changed CollisionGroup player when seated

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.