I have made an Anti Player Collison Script for my game to avoid trollers but it doesnt seem to be working here is the code:
The photo is blurred so here is the code instead:
local Players = game:GetService(“Players”)
local PhysicsService = game:GetService(“PhysicsService”)
local GroupName = “Players”
PhysicsService:CreateCollisionGroup(GroupName)
PhysicsService:CollisionGroupSetCollidable(GroupName, GroupName, false)
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local function ChangeGroup(Part)
if Part:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(Part, "Players")
end
end
Character.ChildAdded:Connect(function(ChangeGroup)
for _, Object in pairs(Character:GetChildren()) do
ChangeGroup(Object)
end
end)
end)
You forgot an end) at the end. This should work though:
local Players = game:GetService(“Players”)
local PhysicsService = game:GetService(“PhysicsService”)
local GroupName = “Players”
PhysicsService:CreateCollisionGroup(GroupName)
PhysicsService:CollisionGroupSetCollidable(GroupName, GroupName, false)
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local function ChangeGroup(Part)
if Part:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(Part, "Players")
end
end
Character.ChildAdded:Connect(function(ChangeGroup)
for _, Object in pairs(Character:GetChildren()) do
ChangeGroup(Object)
end
end)
end)
end)
