Best way to make player massless?

I noticed when working with vehicles that if I turn off player mass during Studio play tests, things work much better. For one, the car doesn’t slide around or tip over when the player bumps it.

What’s the best way to have make player parts massless at start/load time?

edited for clarity

2 Likes

By deactivating player physics, do you mean disabling their collision? If so, just add every player’s limbs and accessories to a CollisionGroup on join that cannot interact with the CollisionGroup containing vehicles.

1 Like

I can do it when a test game is running in Studio by making the body parts massless. That seems to be the most helpful setting to change. It’s a checkbox in Studio but how do I make that default for all players?

The process of setting every instance’s CollisionGroup within players’ characters is very similar, in your case we need to:

  1. Listen for players joining

  2. Connect a function to players’ CharacterAdded event to execute for all spawns upon entrance to the server

  3. Iterate through every descendant of newly spawned characters and ensure that those inheriting BasePart’s properties are massless

Your code should accomplish something like this:

game:GetService'Players'.PlayerAdded:Connect(function(plr) --listen for players joining
	plr.CharacterAdded:Connect(function(chr) --listen for characters spawning
		if game:GetService'StarterPlayer'.LoadCharacterAppearance then --only await character model completion if appearances load
			plr.CharacterAppearanceLoaded:Wait(); --await character model completion
		end
		
		local limbs = chr:GetDescendants();
		for i = 1, #limbs do --yay no pairs loop what a great micro optimization
			if limbs[i]:IsA'BasePart' then --ensure the object inherits basepart because massless is a property inherited from basepart
				limbs[i].Massless = true;
			end
		end
	end)
end)
10 Likes

Thank you! Exactly the detailed explanation I needed.

2 Likes

When the player exits the VehicleSeat, the player’s mass is ALL back, and the player starts skidding on the ground. Any way to fix?

Edit: or else it loses mass as soon as it enters the game.

Theoretically that would make the players pass trough vehicles. If I’m not mistaken.