Fe player collide script
Key RequiredUniversal

Fe player collide script

Universal ScriptEatkidmasterEatkidmaster 1K views 3.4K executesUpdated Sep 12, 2026
Unrated
00
Lua Script•356 lines (7409 chars)
--========================================================--
--PLAYER COLLIDE 
--DRAGABLE UI========================================================--

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

local LocalPlayer = Players.LocalPlayer

local ENABLED = true
local COLLISION_GROUP = "LocalOtherPlayers"

--========================================================--
-- COLLISION GROUP
--========================================================--

pcall(function()
	PhysicsService:RegisterCollisionGroup(COLLISION_GROUP)
end)

pcall(function()
	PhysicsService:CollisionGroupSetCollidable(
		COLLISION_GROUP,
		COLLISION_GROUP,
		true
	)
end)

pcall(function()
	PhysicsService:CollisionGroupSetCollidable(
		COLLISION_GROUP,
		"Default",
		true
	)
end)

--========================================================--
-- GUI
--========================================================--

local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")

local Gui = Instance.new("ScreenGui")
Gui.Name = "OtherPlayerCollision"
Gui.ResetOnSpawn = false
Gui.IgnoreGuiInset = true
Gui.DisplayOrder = 999999
Gui.Parent = PlayerGui

local Button = Instance.new("TextButton")
Button.Name = "CollisionToggle"
Button.Size = UDim2.fromOffset(165, 50)
Button.Position = UDim2.new(1, -180, 1, -75)

Button.BackgroundColor3 = Color3.fromRGB(35, 145, 70)
Button.BorderSizePixel = 0
Button.TextColor3 = Color3.new(1, 1, 1)
Button.TextScaled = true
Button.Font = Enum.Font.GothamBold
Button.Text = "PLAYER COLLISION: ON"

Button.Active = true
Button.AutoButtonColor = false
Button.Parent = Gui

local Corner = Instance.new("UICorner")
Corner.CornerRadius = UDim.new(0, 10)
Corner.Parent = Button

--========================================================--
-- PHYSICS SETTINGS
--========================================================--

local SMOOTH_PHYSICS = PhysicalProperties.new(
	2,      -- Density
	1,      -- Friction
	0,      -- Elasticity = ZERO BOUNCE
	100,    -- FrictionWeight
	0       -- ElasticityWeight
)

--========================================================--
-- BODY PARTS
--========================================================--

local BODY_PART_NAMES = {
	["Head"] = true,

	["Torso"] = true,
	["UpperTorso"] = true,
	["LowerTorso"] = true,

	["Left Arm"] = true,
	["Right Arm"] = true,
	["Left Leg"] = true,
	["Right Leg"] = true,

	["LeftUpperArm"] = true,
	["LeftLowerArm"] = true,
	["LeftHand"] = true,

	["RightUpperArm"] = true,
	["RightLowerArm"] = true,
	["RightHand"] = true,

	["LeftUpperLeg"] = true,
	["LeftLowerLeg"] = true,
	["LeftFoot"] = true,

	["RightUpperLeg"] = true,
	["RightLowerLeg"] = true,
	["RightFoot"] = true,

	["HumanoidRootPart"] = true
}

--========================================================--
-- SET COLLISION
--========================================================--

local function SetCollision(character, enabled)

	if not character then
		return
	end

	-- Never modify our own character
	if character == LocalPlayer.Character then
		return
	end

	for _, object in ipairs(character:GetDescendants()) do

		if object:IsA("BasePart") then

			-- Only the actual character body collides.
			-- Accessories are left non-collidable to reduce
			-- strange physics and bouncing.

			if BODY_PART_NAMES[object.Name] then

				if enabled then

					object.CanCollide = true
					object.CanTouch = true

					pcall(function()
						object.CollisionGroup = COLLISION_GROUP
					end)

					-- Remove elastic bouncing
					object.CustomPhysicalProperties = SMOOTH_PHYSICS

				else

					object.CanCollide = false

					pcall(function()
						object.CollisionGroup = "Default"
					end)

				end

			else
				-- Accessories / handles
				object.CanCollide = false
			end
		end
	end
end

--========================================================--
-- UPDATE ALL OTHER PLAYERS
--========================================================--

local function UpdateAllPlayers()

	for _, player in ipairs(Players:GetPlayers()) do

		if player ~= LocalPlayer then

			if player.Character then
				SetCollision(player.Character, ENABLED)
			end

		end
	end
end

--========================================================--
-- PLAYER SETUP
--========================================================--

local function SetupPlayer(player)

	if player == LocalPlayer then
		return
	end

	player.CharacterAdded:Connect(function(character)

		character:WaitForChild("Humanoid", 10)

		task.wait(0.5)

		SetCollision(character, ENABLED)

		-- Handle body parts added later
		character.DescendantAdded:Connect(function(object)

			if not ENABLED then
				return
			end

			if object:IsA("BasePart") then

				task.wait()

				if BODY_PART_NAMES[object.Name] then

					object.CanCollide = true

					pcall(function()
						object.CollisionGroup = COLLISION_GROUP
					end)

					object.CustomPhysicalProperties = SMOOTH_PHYSICS

				else
					object.CanCollide = false
				end
			end
		end)
	end)
end

for _, player in ipairs(Players:GetPlayers()) do
	SetupPlayer(player)
end

Players.PlayerAdded:Connect(SetupPlayer)

--========================================================--
-- BUTTON
--========================================================--

local function UpdateButton()

	if ENABLED then

		Button.Text = "PLAYER COLLISION: ON"
		Button.BackgroundColor3 = Color3.fromRGB(35, 145, 70)

	else

		Button.Text = "PLAYER COLLISION: OFF"
		Button.BackgroundColor3 = Color3.fromRGB(145, 45, 45)

	end
end

--========================================================--
-- DRAG SYSTEM
--========================================================--

local dragging = false
local dragInput = nil
local dragStart = nil
local startPosition = nil

local function UpdateDrag(input)

	local delta = input.Position - dragStart

	Button.Position = UDim2.new(
		startPosition.X.Scale,
		startPosition.X.Offset + delta.X,

		startPosition.Y.Scale,
		startPosition.Y.Offset + delta.Y
	)
end

Button.InputBegan:Connect(function(input)

	if input.UserInputType == Enum.UserInputType.MouseButton1
		or input.UserInputType == Enum.UserInputType.Touch then

		dragging = true
		dragStart = input.Position
		startPosition = Button.Position

		input.Changed:Connect(function()

			if input.UserInputState == Enum.UserInputState.End then
				dragging = false
			end

		end)
	end
end)

Button.InputChanged:Connect(function(input)

	if input.UserInputType == Enum.UserInputType.MouseMovement
		or input.UserInputType == Enum.UserInputType.Touch then

		dragInput = input
	end
end)

UserInputService.InputChanged:Connect(function(input)

	if input == dragInput and dragging then
		UpdateDrag(input)
	end
end)

--========================================================--
-- TOGGLE
--========================================================--

Button.Activated:Connect(function()

	if dragging then
		return
	end

	ENABLED = not ENABLED

	UpdateButton()
	UpdateAllPlayers()
end)

--========================================================--
-- KEEP COLLISION ACTIVE
--========================================================--

task.spawn(function()

	while task.wait(0.5) do

		if ENABLED then
			UpdateAllPlayers()
		end

	end
end)

--========================================================--
-- START
--========================================================--

UpdateButton()
UpdateAllPlayers()

Features & Information

Make you able to collide player if the game doesn't support collision

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts