Hello, the Collision Group that I made isn’t working. I want the player to not be able to collide with any part named “Glass” in the workspace. (Right now they can collide with it) Here is the code:
local function collisions(player)
local char = player.Character or player.CharacterAdded:Wait()
task.spawn(function()
for i, v in pairs(game.Workspace:GetDescendants()) do
if v.Name == "Glass" then
v.CollisionGroup = "Glass"
end
end
end)
task.spawn(function()
for i, v in pairs(char:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.CollisionGroup = "Player"
end
end
end)
end
task.spawn(function()
for i, v in pairs(char:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
print(v.Name)
v.CollisionGroup = "Player"
end
end
end)
local function setCollisionGroup(instances,collisionGroup)
for _, part in instances do
if part:IsA("BasePart") then
part.CollisionGroup = collisionGroup
end
end
end
setCollisionGroup(char:GetDescendants(),"Player")
local function collisions(player)
local char = player.Character or player.CharacterAdded:Wait()
task.spawn(function()
for i, descendant in ipairs(workspace:GetDescendants()) do
if descendant.Name == "Glass" then
descendant.CollisionGroup = "Glass"
end
end
end)
task.spawn(function()
for i, descendant in ipairs(char:GetDescendants()) do
if descendant:IsA("BasePart") then
descendant.CollisionGroup = "Player"
end
end
end)
end