I am making a script for a football / soccer ball and I dont want to player to collide with the ball since botth the ball and player fly. I used Collision Groups but they are not working.
here’s my script:
local Players = game:GetService("Players")
-- Function to set the collision group for all parts of a character
local function setCollisionGroup(character)
for _, part in ipairs(character:GetDescendants()) do
if part:IsA("BasePart") then
part.CollisionGroup = "Plr"
end
end
end
-- Connect function to player's character added event
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(setCollisionGroup)
end)
-- Apply collision group to all existing players' characters
for _, player in ipairs(Players:GetPlayers()) do
if player.Character then
setCollisionGroup(player.Character)
end
player.CharacterAdded:Connect(setCollisionGroup)
end