I need to check when a player collides with another player

I want my code to detect when a player collides with another player.

Then I want it to freeze one of the players for a certain amount of time.

LargeHotDogs13

Well what you can do is a .Touched for each player and locate the player instance depending on what part is touched.

I would create a “HitBox” part to each character and check if it’s touched then locate if its a player like this:

local BasePart = script.Parent
local Players = game:GetService('Players')

BasePart.Touched:Connect(function(Hit)
	local Player = Players:GetPlayerFromCharacter(Hit.Parent)
	if Player then
		--// The player is found, you can do your code here.
	end
end)

Please mark this as solution if this helps with your problem :smiley: ! If it doesn’t please inform me if about the problem! :slightly_smiling_face:

I would say this:

local BasePart = script.Parent
local Players = game:GetService('Players')

BasePart.Touched:Connect(function(Hit)
	local Player = Players:GetPlayerFromCharacter(Hit.Parent)
	if Player then
		
		local Character = Hit.Parent
		Character.HumanoidRootPart.Anchored = true
		delay(1, function() --// Wait X(1) amount of seconds before you unfreeze the player.
			Character.HumanoidRootPart.Anchored = false
		end)
		
	end
end)