Hello,
I wrote a collision group script:
local physics = game:GetService('PhysicsService')
local collisionGroup = physics:CreateCollisionGroup('group')
local npsGroup = physics:CreateCollisionGroup('npcs')
physics:CollisionGroupSetCollidable('npcs','group',false)
local function main()
for _, mainPart in pairs(workspace.Teacher:GetChildren()) do
if mainPart:IsA('BasePart') then
physics:SetPartCollisionGroup(mainPart,'npcs')
end
end
for _, mainPart in pairs(workspace.Guide:GetChildren()) do
if mainPart:IsA('BasePart') then
physics:SetPartCollisionGroup(mainPart,'npcs')
end
end
for _, doorPart in pairs(workspace.StaffDoor:GetChildren()) do
if doorPart:IsA('BasePart') then
physics:SetPartCollisionGroup(doorPart,'group')
end
end
end
main()
It works, but when I enable it, it breaks my no-collide players script; players and npos can collide. But they shouldn’t be able to.
Here is my no-collide player script:
script.Parent = game:GetService("ServerScriptService")
local PhysService = game:GetService("PhysicsService")
local PlayerGroup = PhysService:CreateCollisionGroup("p")
PhysService:CollisionGroupSetCollidable("p","p",false)
function NoCollide(model)
for k,v in pairs(model:GetChildren()) do
if v:IsA"BasePart" then
PhysService:SetPartCollisionGroup(v,"p")
end
end
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
char:WaitForChild("HumanoidRootPart")
char:WaitForChild("Head")
char:WaitForChild("Humanoid")
wait(0.1)
NoCollide(char)
end)
if player.Character then
NoCollide(player.Character)
end
end)
When I disable the first script, the second one works! How can I make it so that they both work?