Currently, I am making a tower defense game. I have rigs that follow along a path. The problem is, the player can collide with these rigs, pushing them off the path. Currently my script looks like this for collisions
local PhysicsService = game:GetService(“PhysicsService”)
local GROUP_A = “UntouchableRigs”
local GROUP_B = “Players”local function ensureGroup(name)
for _, g in ipairs(PhysicsService:GetRegisteredCollisionGroups()) do
if g.name == name then
return
end
end
local ok, err = pcall(function()
PhysicsService:RegisterCollisionGroup(name)
end)
if not ok then
warn(“Couldn’t register collision group:”, name, err)
end
endensureGroup(GROUP_A)
ensureGroup(GROUP_B)PhysicsService:CollisionGroupSetCollidable(GROUP_A, GROUP_B, false) s
PhysicsService:CollisionGroupSetCollidable(GROUP_A, GROUP_A, false)local function setRigToGroup(rigModel, groupName)
if not rigModel or not rigModel:IsA(“Model”) then
return
endfor _, part in ipairs(rigModel:GetDescendants()) do
if part:IsA(“BasePart”) then
part.CollisionGroup = groupName
part.CanTouch = false
part.CanQuery = falseendend
endlocal enemyfolder = workspace:WaitForChild(“Enemies”)
enemyfolder.ChildAdded:Connect(function(rig)
if rig:IsA(“Model”) then
setRigToGroup(rig, GROUP_A)rig:FindFirstChild("Torso").Changed:Connect(function(property) if property == "CanCollide" then rig:FindFirstChild("Torso").CanCollide = false end end)end
end)
It could be a simple mistake or a huge problem. Whatever you know, please tell me!