I can push objects that aren't in the same collision groups

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

Well, i am making a tower defense game and i put the enemies and the player in a different collision groups using a script. But while i cant collide with the enemies i can push them for some reason.

  1. What is the issue? Include screenshots / videos if possible!

as you can see in the video listed above i can push them, and sometimes they also just decide to disappear.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

script with the player collision group
(server script)

local Players = game:GetService('Players')


Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		for i, object in ipairs(character:GetDescendants()) do
			if object:IsA("Part") then
				object.CollisionGroup = "Player"
			end
		end
	end)
end)

here is my mob module script

local ServerStorage = game:GetService('ServerStorage')
local EasyModeFolder = ServerStorage.Mobs:WaitForChild('EasyMode')
local mob = {}

function mob.Move(mob, map)
	local humanoid = mob:WaitForChild('Humanoid')
	local waypoints = map.Waypoints
	
	for waypoint=1, #waypoints:GetChildren() do
		humanoid:MoveTo(waypoints[waypoint].Position)
		humanoid.MoveToFinished:Wait()
	end
	
	mob:Destroy()
	
end

function mob.Spawn(name, quantity, map)
	local mobExists = ServerStorage.Mobs:FindFirstChild(name)
	
	if mobExists then
		for i=1, quantity do
			task.wait(0.5)
			local newMob = mobExists:Clone()
			newMob.HumanoidRootPart.CFrame = map.Start.CFrame
			newMob.Parent = map.Mob
			newMob.HumanoidRootPart:SetNetworkOwner(nil)
			
			for i, object in ipairs(newMob:GetDescendants()) do
				if object:IsA("Part") then
					object.CollisionGroup = "Mob"
				end
			end

			coroutine.wrap(mob.Move)(newMob, map)
		end
		
	else
		warn('Requested mob, "' .. name .. '" does not exist')
	end
end

return mob

line 29 through 33 is where i set the collision groups for the enemies.

And yes, i am following the gnomecode tutorials as i have no idea how to make a tower defense game.

Help would be appreciated.

1 Like

Try changing :IsA(“Part”) to :IsA(“BasePart”). Did you check that it actually passes the if statement?

3 Likes

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