Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement