0% found this document useful (0 votes)
5 views1 page

No Collision FE

The script manages collision detection between players in a game, allowing for toggling of collision states. It checks the distance between players and disables collision if they are within a specified threshold. The functionality can be enabled or disabled through a global toggle function.

Uploaded by

karebsatoru46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

No Collision FE

The script manages collision detection between players in a game, allowing for toggling of collision states. It checks the distance between players and disables collision if they are within a specified threshold. The functionality can be enabled or disabled through a global toggle function.

Uploaded by

karebsatoru46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

--No obfuscated now, are you happy?

local Players = game:GetService("Players")


local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer

local CHECK_INTERVAL = 0.1


local DIST_THRESHOLD = 20
local Enabled = true

local function getHRP(character)


return character and character:FindFirstChild("HumanoidRootPart")
end

local localHRP = nil


local function onCharacterAdded(character)
localHRP = getHRP(character)
end

LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
if LocalPlayer.Character then
onCharacterAdded(LocalPlayer.Character)
end

local accumulated = 0
RunService.Heartbeat:Connect(function(dt)
if not Enabled then return end -- ถ้าปิดระบบ ไม่ทำงาน

accumulated = accumulated + dt
if accumulated < CHECK_INTERVAL then return end
accumulated = 0

if not localHRP then return end


local localPos = localHRP.Position

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


if player ~= LocalPlayer and player.Character then
local otherHRP = getHRP(player.Character)
if otherHRP then
local dist = (otherHRP.Position - localPos).Magnitude
local shouldCollide = true
if dist < DIST_THRESHOLD then
shouldCollide = false
end
-- อัปเดทเฉพาะตอนที่เปลี่ยนแปลง
for _, part in ipairs(player.Character:GetDescendants()) do
if part:IsA("BasePart") and part.CanCollide ~= shouldCollide
then
part.CanCollide = shouldCollide
end
end
end
end
end
end)

_G.ToggleNoCollision = function(state)
Enabled = state
end

You might also like