Scripting help with character

can someone tell me why this isnt working?

repeat wait() until game:IsLoaded()
	
local function onCharacterAdded(character)
	print("g")
	local player = script.Parent
	local PhysicsService = game:GetService("PhysicsService")
	for i,v in pairs(player:GetDescendants()) do
		if v:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(v, "Players")
			print("f")
		end
	end
end
1 Like

You have connected 0 events.

Code (taken from https://create.roblox.com/docs/workspace/collisions):

local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")

PhysicsService:RegisterCollisionGroup("Players")
PhysicsService:CollisionGroupSetCollidable("Players", "Players", false)

local function onDescendantAdded(descendant)
	-- Set collision group for any part descendant
	if descendant:IsA("BasePart") then
		descendant.CollisionGroup = "Players"
	end
end

local function onCharacterAdded(character)
	-- Process existing and new descendants for physics setup
	for _, descendant in character:GetDescendants() do
		onDescendantAdded(descendant)
	end
	character.DescendantAdded:Connect(onDescendantAdded)
end

Players.PlayerAdded:Connect(function(player)
	-- Detect when the player's character is added
	player.CharacterAdded:Connect(onCharacterAdded)
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.