How to prevent collisions with locally created NPCs?

Making a turn-based combat style game in which the player might bump into some enemy NPCs, so I wanna prevent them from being able to collide with each other.
Got this collision script I’ve been using in the past. It’s in a LocalScript that I put in ReplicatedFirst.

local P = game:GetService("PhysicsService") --Handling collisions
local groupName = "Battle"	
P:CreateCollisionGroup(groupName)
P:CollisionGroupSetCollidable(groupName, groupName, false)	
local function setGroup(object)
	if object:IsA("BasePart") then
		P:SetPartCollisionGroup(object, groupName)
	end
end	
local function setGroupRecursive(object)
	setGroup(object)
	for _, child in ipairs(object:GetChildren()) do
		setGroupRecursive(child)
	end
end	
local function noCollide(character)
	setGroupRecursive(character)
	character.DescendantAdded:Connect(setGroup)
end	
local player = game:GetService("Players").LocalPlayer
local playerChar = player.Character or player.CharacterAdded:Wait()
noCollide(playerChar) --Ensure the player cannot collide with rendered enemies

The reason why the NPCs are locally created is to reduce lag. There’s gonna be lots of enemy NPCs, thus lots of humanoids, so what I’m doing is creating just a singular part on the server that moves in a specified path while the client renders a character model for them. Anyway, that’s not important.

Before I even started adding the NPCs to the collision group, I’ve just discovered for the first time that the CollisionGroup API can only be used on the server. Yikes. The error output I got was: This API can only be used on the server!

So since CollisionGroups are now out of the question, how can I prevent the player from colliding with NPCs that are created on the client?

Nevermind, I figured it out! I should’ve done more research.

Recently, certain CollisionGroup functions were made available to the client, as shown here. All I had to do was move server-only functions to the Workspace. Thankfully, I can add local NPCs to collision groups.

Thanks anyway! :slight_smile: