This is a no collision script for both Players and NPC and it works. But every an error pops up and I don’t know how to fix it
"SetPartCollisionGroup is deprecated, please use BasePart.CollisionGroup instead. More info: Updates to Collision Groups "
I went to the website and it said “SetPartCollisionGroup : To be deprecated. Replaced by calling BasePart.CollisionGroup”. I still don’t get how to put this in the script and make the error go away.
This is in ServerScriptService
--PlayerCollision
local Players = game:GetService("Players")
local PS = game:GetService("PhysicsService")
local CollisionGroupName = "Players"
PS:RegisterCollisionGroup(CollisionGroupName)
PS:CollisionGroupSetCollidable(CollisionGroupName, CollisionGroupName, false)
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
local function ChangeGroup(Part)
if Part:IsA("BasePart") then
PS:SetPartCollisionGroup(Part, CollisionGroupName)
end
end
char.ChildAdded:Connect(ChangeGroup)
for _, Object in pairs(char:GetChildren()) do
ChangeGroup(Object)
end
end)
end)
--NPCCollision
local npcs= workspace.Dummy
local ps=game:GetService("PhysicsService")
while true do
task.wait()
ps:RegisterCollisionGroup("PlayersGroup")
ps:RegisterCollisionGroup("NpcsGroup")
ps:CollisionGroupSetCollidable("PlayersGroup", "NpcsGroup", false)
for _,npc in pairs(npcs:GetChildren()) do
for _,v in pairs(npc:GetDescendants()) do
if v:IsA("BasePart") then
ps:SetPartCollisionGroup(v,"NpcsGroup")
end
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
task.wait()
for _,v in pairs(char:GetChildren()) do
if v:IsA("BasePart") then
ps:SetPartCollisionGroup(v,"PlayersGroup")
end
end
end)
end)
end
--PlayerCollision
local Players = game:GetService("Players")
local PS = game:GetService("PhysicsService")
local CollisionGroupName = "Players"
PS:RegisterCollisionGroup(CollisionGroupName)
PS:CollisionGroupSetCollidable(CollisionGroupName, CollisionGroupName, false)
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
local function ChangeGroup(Part)
if Part:IsA("BasePart") then
PS:SetPartCollisionGroup(Part, CollisionGroupName)
end
end
char.ChildAdded:Connect(ChangeGroup)
for _, Object in pairs(char:GetChildren()) do
ChangeGroup(Object)
end
end)
end)
Ok I got it thanks.
I replaced the PlayerCollision to
Part.CollisionGroup = CollisionGroupName
I replaced the NPCCollision to
v.CollisionGroup = "PlayersGroup"
v.CollisionGroup = "NpcsGroup"
--PlayerCollision
local Players = game:GetService("Players")
local PS = game:GetService("PhysicsService")
local CollisionGroupName = "Players"
PS:RegisterCollisionGroup(CollisionGroupName)
PS:CollisionGroupSetCollidable(CollisionGroupName, CollisionGroupName, false)
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
local function ChangeGroup(Part)
if Part:IsA("BasePart") then
Part.CollisionGroup = CollisionGroupName
end
end
char.ChildAdded:Connect(ChangeGroup)
for _, Object in pairs(char:GetChildren()) do
ChangeGroup(Object)
end
end)
end)
--NPCCollision
local npcs= workspace.Dummy
local ps=game:GetService("PhysicsService")
while true do
task.wait()
ps:RegisterCollisionGroup("PlayersGroup")
ps:RegisterCollisionGroup("NpcsGroup")
ps:CollisionGroupSetCollidable("PlayersGroup", "NpcsGroup", false)
for _,npc in pairs(npcs:GetChildren()) do
for _,v in pairs(npc:GetDescendants()) do
if v:IsA("BasePart") then
v.CollisionGroup = "NpcsGroup"
end
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
task.wait()
for _,v in pairs(char:GetChildren()) do
if v:IsA("BasePart") then
v.CollisionGroup = "PlayersGroup"
end
end
end)
end)
end