Help with making all players other than localPlayer CanCollide off

hello, im trying to make player collision off, but i have viewmodels to change the first person and collision groups so when i use other scripts it glitches the game bad, so im trying to make a script that gets players, make sures it isnt the local player, then gets decedents, makes sure its a meshpart or a part, then makes cancolldie off, any help?


local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()


local function CollsionOff(player_)
	local Player = game.Players
	if Player.Name ~= game.Players.LocalPlayer.Name then
		
	for i,v in pairs (Player.Character:GetDescendants()) do
		if v:IsA("BasePart") or v:IsA("Decal") then
			v.CanCollide= 1
			end
		end
	end
end

1 Like

you dont have to do all of that, just place the players into a collisiongroup that cant collide with itself. theres script in the roblox documentation that does exactly this:

you cant actually change the cancollide value of characters with a humanoid because the game autosets it. otherwise, the collisions would mess with the character physics.

1 Like