Remove accessories when player is sitting in a vehicleseat

  1. I want to remove accessories when player is sitting in a vehicleseat and when the player leaves that seat they will get their accessories back.

  2. Im not sure how to do this. I’ve heard if humanoid:RemoveAccessories(), but I don’t really understand how i would save them.

  3. I tried to do this myself, but for some reason, the accessories would only come back sometimes.

1 Like

here, I typed something up quick in studio. Try this out.

This is a server script that goes into the seat.

local lastplayer
script.Parent:GetPropertyChangedSignal("Occupant"):Connect(function()
    if script.Parent.Occupant == nil then
        if lastplayer then
            local hatfolder = game.ReplicatedStorage:FindFirstChild(lastplayer.Name)
            for _,v in pairs(hatfolder:GetChildren()) do
                v.Parent = lastplayer
            end
            hatfolder:Destroy()
            lastplayer = nil
            return
        end
    end
    
    local plr = script.Parent.Occupant.Parent
    lastplayer = plr
    local folder = Instance.new("Folder")
    folder.Name = plr.Name
    folder.Parent = game.ReplicatedStorage
    
    for _,v in pairs(plr:GetChildren()) do
        if v:IsA("Accessory") then
            v.Parent = folder
        end
    end
end)
2 Likes

I’m gonna go to sleep now. I’ll try it in the morning.

1 Like

Thanks for the help! It worked great. I’ll be sure to use it in my game. Would you like credit?

1 Like

I don’t care if you credit me or not. After all I did was help you out with some code.

1 Like