[Help Required!] Collision Group not working

Hi! I’m making a tower defence game and players can’t collide with other players, monsters or towers. Only in studio. As soon as I get teleported into the game from the lobby, I can suddenly collide with towers and monsters. Sometimes I don’t collide while my friends do and sometimes I do too.

I have a script for the players, mobs and towers. I’ll only send the CollisionGroup part of the script:
Mobs:

for i, object in ipairs(newmob:GetDescendants()) do
				if object:IsA("BasePart") then
					object.CollisionGroup = "Mob"
				end
			end

Players:

player.CharacterAdded:Connect(function(char)
		for i, object in ipairs(char:GetDescendants()) do
			if object:IsA("BasePart") then
				object.CollisionGroup = "Player"
				print(object.CollisionGroup)
			end
		end
	end)

Towers:

for i, object in ipairs(newtower:GetDescendants()) do
			if object:IsA("BasePart") then
				object.CollisionGroup = "Tower"
			end
		end

Here is also the collision group table thing:

Thanks so much for any help as this has been a problem for a while. :slight_smile:

3 Likes

for Player.Character collisions i recommend this:

player.CharacterAdded:Connect(function(char)
        function NoCollide(object)
            if object:IsA("BasePart") then
				object.CollisionGroup = "Player"
				print(object.CollisionGroup)
			end
         end
        char.DescendantAdded:Connect(NoCollide)
		for i, object in ipairs(char:GetDescendants()) do
             task.spawn(NoCollide,object)
		end
	end)
3 Likes

Are these local scripts or server scripts.
Typically if something works in Studio and not in game it’s because in Studio your computer is running all the server scripts as well as the local scripts. In game the actual server is running the server scripts and your computer is running local scripts.

1 Like

They are all server scripts or modules. Towers and mobs are modules and player is server.

1 Like

Check out the Disabling Character Collisions section here: Collisions | Documentation - Roblox Creator Hub

2 Likes

I looked everywhere through this and have found nothing that worked. Thanks though

1 Like

Update: The collision group works for me in game but as soon as my friends test they collide with other things. I tried printing their HumanoidRootPart’s collision group and that returned as Player. This makes no sense. I’m still looking for help

2 Likes

This doesn’t work for me, “NoCollide” comes out with an orange line, but it worked for me by putting “local” after “function”, other than that, thanks to you now the collisions in my game work very well :slight_smile:

1 Like