Guest

Deluxed Hub free soft open src

May 10th, 2026
14
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
None 53.12 KB | None | 0 0
  1. local cloneref = cloneref or function(x) return x end
  2. local Workspace = cloneref(game:GetService("Workspace"))
  3. local Players = cloneref(game:GetService("Players"))
  4. local RunService = cloneref(game:GetService("RunService"))
  5. local UIS = cloneref(game:GetService("UserInputService"))
  6. local Lighting = cloneref(game:GetService("Lighting"))
  7. local CoreGui = cloneref(game:GetService("CoreGui"))
  8. local LocalPlayer = Players.LocalPlayer
  9. local Camera = Workspace.CurrentCamera
  10.  
  11. local trident = { middlepart = nil, tcp = nil, original_model = nil }
  12. repeat
  13. local ok = pcall(function()
  14. trident.middlepart = Workspace.Const.Ignore.LocalCharacter.Middle
  15. trident.tcp = LocalPlayer and LocalPlayer.TCP
  16. trident.original_model = game:GetService("ReplicatedStorage").Shared.entities.Player.Model
  17. end)
  18. if not ok or not (trident.middlepart and trident.tcp and trident.original_model) then task.wait(0.25) end
  19. until trident.middlepart and trident.tcp and trident.original_model
  20.  
  21. local okRF, Rayfield = pcall(function()
  22. return loadstring(game:HttpGet("https://sirius.menu/rayfield"))()
  23. end)
  24. if not okRF or not Rayfield then
  25. warn("Rayfield не загрузился. Проверь HttpGet/экзекьютор.")
  26. return
  27. end
  28.  
  29. local Window = Rayfield:CreateWindow({
  30. Name = "Deluxed Hub | Trident Survival",
  31. Icon = 0,
  32. LoadingTitle = "Deluxed Hub <3",
  33. LoadingSubtitle = "Trident Survival",
  34. ShowText = "Del3xed",
  35. Theme = "Default",
  36. ToggleUIKeybind = "L",
  37. DisableRayfieldPrompts = false,
  38. DisableBuildWarnings = false,
  39. ConfigurationSaving = {
  40. Enabled = true,
  41. FolderName = "deluxedhub_rf",
  42. FileName = "config_rf"
  43. }
  44. })
  45.  
  46. local ESPTab = Window:CreateTab("ESP (Head)")
  47.  
  48. local ESP = {
  49. enabled = true,
  50. showName = false,
  51. showDistance = true,
  52. colorByDistance = true,
  53. textColor = Color3.fromRGB(0,255,0),
  54. textStroke = true,
  55. textSize = 16,
  56. bbWidth = 160,
  57. bbHeight = 42,
  58. studsOffsetY = 2,
  59. maxDistance = 10000, -- 0 = бесконечность
  60. alwaysOnTop = true,
  61. ignoreLocalHead = true,
  62. }
  63.  
  64. local Heads = {} -- [BasePart] = {bill=BillboardGui, label=TextLabel, ancestryCon=RBXScriptConnection}
  65.  
  66. local function isLocalHead(part)
  67. local char = LocalPlayer and LocalPlayer.Character
  68. if not char then return false end
  69. local h = char:FindFirstChild("Head")
  70. return h == part
  71. end
  72.  
  73. local function applyVisualToOne(head, data)
  74. local bill, label = data.bill, data.label
  75. bill.Enabled = ESP.enabled
  76. bill.AlwaysOnTop = ESP.alwaysOnTop
  77. bill.Size = UDim2.new(0, ESP.bbWidth, 0, ESP.bbHeight)
  78. bill.StudsOffset = Vector3.new(0, ESP.studsOffsetY, 0)
  79. pcall(function()
  80. bill.MaxDistance = (ESP.maxDistance and ESP.maxDistance > 0) and ESP.maxDistance or math.huge
  81. end)
  82. label.TextStrokeTransparency = ESP.textStroke and 0 or 1
  83. label.TextScaled = false
  84. label.TextSize = ESP.textSize
  85. if not ESP.colorByDistance then
  86. label.TextColor3 = ESP.textColor
  87. end
  88. end
  89.  
  90. local function applyVisualToAll()
  91. for head, data in pairs(Heads) do
  92. if head and head.Parent and data and data.label then
  93. applyVisualToOne(head, data)
  94. end
  95. end
  96. end
  97.  
  98. local function removeHead(head)
  99. local data = Heads[head]
  100. if not data then return end
  101. if data.ancestryCon then data.ancestryCon:Disconnect() end
  102. if data.bill then data.bill:Destroy() end
  103. Heads[head] = nil
  104. end
  105.  
  106. local function createHeadESP(head)
  107. if not head or not head:IsA("BasePart") or head.Name ~= "Head" then return end
  108. if ESP.ignoreLocalHead and isLocalHead(head) then return end
  109. if Heads[head] or head:FindFirstChild("HeadESP") then return end
  110.  
  111. local bill = Instance.new("BillboardGui")
  112. bill.Name = "HeadESP"
  113. bill.Adornee = head
  114. bill.AlwaysOnTop = ESP.alwaysOnTop
  115. bill.Size = UDim2.new(0, ESP.bbWidth, 0, ESP.bbHeight)
  116. bill.StudsOffset = Vector3.new(0, ESP.studsOffsetY, 0)
  117. bill.Enabled = ESP.enabled
  118. pcall(function()
  119. bill.MaxDistance = (ESP.maxDistance and ESP.maxDistance > 0) and ESP.maxDistance or math.huge
  120. end)
  121.  
  122. -- аккуратный фон с округлением
  123. local bg = Instance.new("Frame")
  124. bg.BackgroundTransparency = 0.25
  125. bg.BackgroundColor3 = Color3.fromRGB(20,20,25)
  126. bg.Size = UDim2.new(1,0,1,0)
  127. bg.Parent = bill
  128. local corner = Instance.new("UICorner"); corner.CornerRadius = UDim.new(0, 10); corner.Parent = bg
  129. local stroke = Instance.new("UIStroke"); stroke.Thickness = 1; stroke.Color = Color3.fromRGB(60,60,75); stroke.Parent = bg
  130.  
  131. local label = Instance.new("TextLabel")
  132. label.BackgroundTransparency = 1
  133. label.Text = "..."
  134. label.TextColor3 = ESP.textColor
  135. label.TextStrokeTransparency = ESP.textStroke and 0 or 1
  136. label.Font = Enum.Font.GothamBold
  137. label.TextScaled = false
  138. label.TextSize = ESP.textSize
  139. label.Size = UDim2.new(1, 0, 1, 0)
  140. label.ZIndex = 2
  141. label.Parent = bill
  142.  
  143. bill.Parent = head
  144.  
  145. local ancestryCon = head.AncestryChanged:Connect(function()
  146. if not head:IsDescendantOf(Workspace) then
  147. removeHead(head)
  148. end
  149. end)
  150.  
  151. Heads[head] = { bill = bill, label = label, ancestryCon = ancestryCon }
  152. applyVisualToOne(head, Heads[head])
  153. end
  154.  
  155. local function rescanHeads()
  156. for head in pairs(Heads) do removeHead(head) end
  157. for _, inst in ipairs(Workspace:GetDescendants()) do
  158. if inst:IsA("BasePart") and inst.Name == "Head" then
  159. createHeadESP(inst)
  160. end
  161. end
  162. end
  163.  
  164. -- init + watch
  165. rescanHeads()
  166. Workspace.DescendantAdded:Connect(function(inst)
  167. if inst:IsA("BasePart") and inst.Name == "Head" then
  168. createHeadESP(inst)
  169. end
  170. end)
  171.  
  172. -- обновление текста/цвета
  173. RunService.RenderStepped:Connect(function()
  174. local origin
  175. local char = LocalPlayer and LocalPlayer.Character
  176. if char then
  177. local hrp = char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso")
  178. origin = hrp and hrp.Position
  179. end
  180. origin = origin or (Camera and Camera.CFrame.Position) or Vector3.new()
  181.  
  182. for head, data in pairs(Heads) do
  183. if head and head.Parent and data and data.label then
  184. local d = math.floor((head.Position - origin).Magnitude + 0.5)
  185. local nameText = (ESP.showName and (head.Parent and head.Parent.Name or "Head")) or nil
  186. local distText = (ESP.showDistance and string.format("[%d м]", d)) or nil
  187.  
  188. if nameText and distText then
  189. data.label.Text = nameText .. " " .. distText
  190. elseif nameText then
  191. data.label.Text = nameText
  192. elseif distText then
  193. data.label.Text = distText
  194. else
  195. data.label.Text = ""
  196. end
  197.  
  198. if ESP.colorByDistance then
  199. if d < 15 then
  200. data.label.TextColor3 = Color3.fromRGB(255, 60, 60)
  201. elseif d < 40 then
  202. data.label.TextColor3 = Color3.fromRGB(255, 220, 0)
  203. else
  204. data.label.TextColor3 = Color3.fromRGB(0, 255, 0)
  205. end
  206. end
  207. end
  208. end
  209. end)
  210.  
  211. -- Rayfield UI (ESP)
  212. ESPTab:CreateToggle({ Name = "ESP Enabled", CurrentValue = ESP.enabled, Callback=function(v) ESP.enabled=v; applyVisualToAll() end })
  213. ESPTab:CreateToggle({ Name = "Показывать имя модели", CurrentValue = ESP.showName, Callback=function(v) ESP.showName=v end })
  214. ESPTab:CreateToggle({ Name = "Показывать дистанцию", CurrentValue = ESP.showDistance, Callback=function(v) ESP.showDistance=v end })
  215. ESPTab:CreateToggle({ Name = "Цвет по расстоянию", CurrentValue = ESP.colorByDistance, Callback=function(v) ESP.colorByDistance=v; applyVisualToAll() end })
  216. ESPTab:CreateToggle({ Name = "Обводка текста", CurrentValue = ESP.textStroke, Callback=function(v) ESP.textStroke=v; applyVisualToAll() end })
  217. ESPTab:CreateToggle({ Name = "AlwaysOnTop", CurrentValue = ESP.alwaysOnTop, Callback=function(v) ESP.alwaysOnTop=v; applyVisualToAll() end })
  218. ESPTab:CreateToggle({ Name = "Игнорировать свою голову", CurrentValue = ESP.ignoreLocalHead, Callback=function(v) ESP.ignoreLocalHead=v; rescanHeads() end })
  219.  
  220. ESPTab:CreateColorPicker({ Name = "Цвет текста (если выкл. окраску по дистанции)", Color = ESP.textColor, Callback=function(c) ESP.textColor=c; if not ESP.colorByDistance then applyVisualToAll() end end })
  221. ESPTab:CreateSlider({ Name="Размер текста", Range={10,72}, Increment=1, CurrentValue=ESP.textSize, Callback=function(val) ESP.textSize=math.floor(val); applyVisualToAll() end })
  222. ESPTab:CreateSlider({ Name="Ширина Billboard", Range={80,400}, Increment=2, CurrentValue=ESP.bbWidth, Callback=function(val) ESP.bbWidth=math.floor(val); applyVisualToAll() end })
  223. ESPTab:CreateSlider({ Name="Высота Billboard", Range={24,200}, Increment=2, CurrentValue=ESP.bbHeight, Callback=function(val) ESP.bbHeight=math.floor(val); applyVisualToAll() end })
  224. ESPTab:CreateSlider({ Name="OffsetY", Range={-10,12}, Increment=0.5, CurrentValue=ESP.studsOffsetY, Callback=function(val) ESP.studsOffsetY=val; applyVisualToAll() end })
  225. ESPTab:CreateSlider({ Name="MaxDistance (0 = бесконечно)", Range={0,20000}, Increment=50, CurrentValue=ESP.maxDistance, Callback=function(val) ESP.maxDistance=math.max(0, math.floor(val)); applyVisualToAll() end })
  226. ESPTab:CreateButton({ Name="Rescan (пересканировать головы)", Callback = rescanHeads })
  227. ESPTab:CreateButton({
  228. Name="Reset (сброс настроек)",
  229. Callback=function()
  230. ESP = {
  231. enabled = true, showName=false, showDistance=true, colorByDistance=true,
  232. textColor=Color3.fromRGB(0,255,0), textStroke=true, textSize=16,
  233. bbWidth=160, bbHeight=42, studsOffsetY=2, maxDistance=10000,
  234. alwaysOnTop=true, ignoreLocalHead=true
  235. }
  236. applyVisualToAll()
  237. rescanHeads()
  238. end
  239. })
  240.  
  241. -- ========== TimeChanger ==========
  242. local WorldTab = Window:CreateTab("World")
  243. local timeEnabled, timeVal = false, math.floor(Lighting.ClockTime + 0.5)
  244. WorldTab:CreateToggle({ Name="Time changer", CurrentValue=false, Callback=function(v) timeEnabled=v end })
  245. WorldTab:CreateSlider({ Name="ClockTime", Range={0,24}, Increment=0.1, CurrentValue=timeVal, Callback=function(v) timeVal=v end })
  246. RunService.Heartbeat:Connect(function()
  247. if timeEnabled then Lighting.ClockTime = timeVal end
  248. end)
  249.  
  250. -- ========== SpeedHack ==========
  251. local SpeedTab = Window:CreateTab("SpeedHack")
  252. local Speed = {
  253. enabled=false, forceSprint=false,
  254. speed=55, minSpeed=17, decay=20, sprintSpeed=18,
  255. requireShift=true, holdKey=Enum.KeyCode.C
  256. }
  257. local boost, t, lastActive = Speed.speed, 0, false
  258.  
  259. local function getMiddle()
  260. if trident.middlepart and trident.middlepart.Parent then return trident.middlepart end
  261. local ok = pcall(function()
  262. trident.middlepart = Workspace.Const.Ignore.LocalCharacter.Middle
  263. end)
  264. if ok then return trident.middlepart end
  265. return nil
  266. end
  267. local function flat(v) return Vector3.new(v.X,0,v.Z) end
  268. local function getMoveDir()
  269. local look = flat(Camera.CFrame.LookVector)
  270. if look.Magnitude < 1e-6 then look = Vector3.new(0,0,-1) end
  271. look = look.Unit
  272. local right = Vector3.new(-look.Z,0,look.X)
  273. local dir = Vector3.zero
  274. if UIS:IsKeyDown(Enum.KeyCode.W) then dir += look end
  275. if UIS:IsKeyDown(Enum.KeyCode.S) then dir -= look end
  276. if UIS:IsKeyDown(Enum.KeyCode.D) then dir += right end
  277. if UIS:IsKeyDown(Enum.KeyCode.A) then dir -= right end
  278. if dir.Magnitude > 1e-6 then dir = dir.Unit end
  279. return dir
  280. end
  281.  
  282. RunService.RenderStepped:Connect(function(dt)
  283. local mid = getMiddle()
  284. if not mid then boost=Speed.speed; t=0; lastActive=false; return end
  285.  
  286. local keyC = UIS:IsKeyDown(Speed.holdKey)
  287. local shiftOK = (not Speed.requireShift) or UIS:IsKeyDown(Enum.KeyCode.LeftShift)
  288. local dir = getMoveDir()
  289. local active = Speed.enabled and keyC and shiftOK and (dir ~= Vector3.zero)
  290.  
  291. if active then
  292. if t==0 then
  293. mid.CFrame = mid.CFrame + Vector3.new(0,6.5,0)
  294. end
  295. boost = math.clamp(boost - dt*Speed.decay, Speed.minSpeed, Speed.speed)
  296. local y = (t < 0.85) and 0 or -7
  297. mid.AssemblyLinearVelocity = Vector3.new(dir.X*boost, y, dir.Z*boost)
  298. t += dt
  299. lastActive = true
  300. else
  301. if lastActive then boost=Speed.speed; t=0; lastActive=false end
  302. if Speed.forceSprint and (dir ~= Vector3.zero) then
  303. local v = mid.AssemblyLinearVelocity
  304. mid.AssemblyLinearVelocity = Vector3.new(dir.X*Speed.sprintSpeed, v.Y, dir.Z*Speed.sprintSpeed)
  305. end
  306. end
  307. end)
  308.  
  309. SpeedTab:CreateToggle({ Name="enabled", CurrentValue=Speed.enabled, Callback=function(v) Speed.enabled=v; if not v then boost=Speed.speed; t=0; lastActive=false end end })
  310. SpeedTab:CreateToggle({ Name="forcesprint", CurrentValue=Speed.forceSprint, Callback=function(v) Speed.forceSprint=v end })
  311. SpeedTab:CreateSlider({ Name="speed", Range={55,70}, Increment=1, Suffix="sps", CurrentValue=Speed.speed, Callback=function(v) Speed.speed=math.floor(v); boost=Speed.speed end })
  312. SpeedTab:CreateSection("Дополнительно")
  313. SpeedTab:CreateToggle({ Name="требовать LeftShift с C", CurrentValue=Speed.requireShift, Callback=function(v) Speed.requireShift=v end })
  314. SpeedTab:CreateSlider({ Name="minSpeed", Range={10,30}, Increment=1, CurrentValue=Speed.minSpeed, Callback=function(v) Speed.minSpeed=math.floor(v) end })
  315. SpeedTab:CreateSlider({ Name="decay", Range={5,40}, Increment=1, Suffix="/s", CurrentValue=Speed.decay, Callback=function(v) Speed.decay=math.floor(v) end })
  316. SpeedTab:CreateSlider({ Name="force sprint speed", Range={10,40}, Increment=1, CurrentValue=Speed.sprintSpeed, Callback=function(v) Speed.sprintSpeed=math.floor(v) end })
  317.  
  318. -- ========== Hitbox Expander (Head) ==========
  319. local HitboxTab = Window:CreateTab("Hitbox")
  320. local hb = { enabled=false, canCollide=false, transp=0.5, sizeX=10, sizeY=10 }
  321. local original_head_size = trident.original_model and trident.original_model:FindFirstChild("Head") and trident.original_model.Head.Size or Vector3.new(2,1,1)
  322.  
  323. -- кэш валидных персонажей (модели с Head и LowerTorso)
  324. local valid = {}
  325. local function addValid(m)
  326. if m:IsA("Model") and m:FindFirstChild("Head") and (m:FindFirstChild("LowerTorso") or m:FindFirstChild("HumanoidRootPart")) then
  327. valid[m] = true
  328. end
  329. end
  330. local function removeValid(m)
  331. if valid[m] then valid[m] = nil end
  332. end
  333. for _,v in ipairs(Workspace:GetChildren()) do addValid(v) end
  334. Workspace.ChildAdded:Connect(addValid)
  335. Workspace.ChildRemoved:Connect(removeValid)
  336.  
  337. -- основной цикл
  338. RunService.Heartbeat:Connect(function()
  339. if hb.enabled then
  340. local size = Vector3.new(hb.sizeX, hb.sizeY, hb.sizeX)
  341. for m in pairs(valid) do
  342. local head = m and m:FindFirstChild("Head")
  343. if head and head:IsA("BasePart") then
  344. head.Size = size
  345. head.Transparency = hb.transp
  346. head.CanCollide = hb.canCollide
  347. end
  348. end
  349. end
  350. end)
  351.  
  352. local function restoreHeads()
  353. for m in pairs(valid) do
  354. local head = m and m:FindFirstChild("Head")
  355. if head and head:IsA("BasePart") then
  356. head.Size = original_head_size
  357. head.Transparency = 0
  358. head.CanCollide = true
  359. end
  360. end
  361. end
  362.  
  363. HitboxTab:CreateToggle({ Name="hitbox expander", CurrentValue=false, Callback=function(v)
  364. hb.enabled = v
  365. if not v then restoreHeads() end
  366. end })
  367. HitboxTab:CreateToggle({ Name="can collide", CurrentValue=hb.canCollide, Callback=function(v) hb.canCollide=v end })
  368. HitboxTab:CreateSlider({ Name="transparency", Range={0,1}, Increment=0.05, CurrentValue=hb.transp, Callback=function(v) hb.transp=v end })
  369. HitboxTab:CreateSlider({ Name="size XZ", Range={1,15}, Increment=1, CurrentValue=hb.sizeX, Callback=function(v) hb.sizeX=math.floor(v) end })
  370. HitboxTab:CreateSlider({ Name="size Y", Range={1,15}, Increment=1, CurrentValue=hb.sizeY, Callback=function(v) hb.sizeY=math.floor(v) end })
  371. HitboxTab:CreateButton({ Name="Restore original", Callback=restoreHeads })
  372.  
  373. -- ========== Car Fly (ATV) ==========
  374. local CarTab = Window:CreateTab("Car Fly")
  375. local carSettings = { enabled=false, speed=150, upspeed=15, accel=100 }
  376. CarTab:CreateToggle({ Name="car fly enabled", CurrentValue=false, Callback=function(v) carSettings.enabled=v end })
  377. CarTab:CreateSlider({ Name="speed", Range={50,300}, Increment=1, Suffix="sps", CurrentValue=carSettings.speed, Callback=function(v) carSettings.speed=math.floor(v) end })
  378. CarTab:CreateSlider({ Name="up speed", Range={5,100}, Increment=1, Suffix="sps", CurrentValue=carSettings.upspeed, Callback=function(v) carSettings.upspeed=math.floor(v) end })
  379. CarTab:CreateSlider({ Name="acceleration", Range={10,300}, Increment=1, CurrentValue=carSettings.accel, Callback=function(v) carSettings.accel=math.floor(v) end })
  380. CarTab:CreateLabel("Управление: WASD, V (вверх), B (вниз)")
  381.  
  382. local car, lastDist = nil, 50
  383. local function findCar()
  384. car, lastDist = nil, 50
  385. for _,v in ipairs(Workspace:GetChildren()) do
  386. if v:FindFirstChild("Seat") and v:FindFirstChild("Frame") then
  387. local mp = trident.middlepart or (Workspace.Const and Workspace.Const.Ignore and Workspace.Const.Ignore.LocalCharacter and Workspace.Const.Ignore.LocalCharacter.Middle)
  388. if mp then
  389. local d = (v.Frame.Position - mp.Position).Magnitude
  390. if d < lastDist then
  391. car = v
  392. lastDist = d
  393. end
  394. end
  395. end
  396. end
  397. end
  398. findCar()
  399.  
  400. local buildup = 0
  401. local lastdir = Vector3.new(1,0,0)
  402. RunService.RenderStepped:Connect(function(dt)
  403. if not carSettings.enabled then buildup = 0 return end
  404. if not car or not car:FindFirstChild("Frame") then
  405. findCar()
  406. buildup = 0
  407. return
  408. end
  409. if (car.Frame.CFrame.Position - Camera.CFrame.Position).Magnitude > 50 then
  410. findCar()
  411. buildup = 0
  412. return
  413. end
  414.  
  415. local cam = Camera.CFrame.LookVector
  416. cam = Vector3.new(cam.X, 0, cam.Z)
  417. local dir = Vector3.zero
  418. if UIS:IsKeyDown(Enum.KeyCode.W) then dir += cam end
  419. if UIS:IsKeyDown(Enum.KeyCode.S) then dir -= cam end
  420. if UIS:IsKeyDown(Enum.KeyCode.D) then dir += Vector3.new(-cam.Z, 0, cam.X) end
  421. if UIS:IsKeyDown(Enum.KeyCode.A) then dir += Vector3.new(cam.Z, 0, -cam.X) end
  422. if UIS:IsKeyDown(Enum.KeyCode.V) then dir += Vector3.yAxis end
  423. if UIS:IsKeyDown(Enum.KeyCode.B) then dir -= Vector3.yAxis end
  424. if dir ~= Vector3.zero then
  425. dir = dir.Unit
  426. if dir.Y == 0 then
  427. buildup = math.clamp(buildup + dt*carSettings.accel, 0, carSettings.speed)
  428. lastdir = dir
  429. end
  430. else
  431. dir = lastdir
  432. buildup = math.clamp(buildup - dt*150, 0, carSettings.speed)
  433. end
  434.  
  435. for _,part in ipairs(car:GetChildren()) do
  436. if part:IsA("BasePart") then
  437. part.AssemblyLinearVelocity = Vector3.new(dir.X*buildup, dir.Y*carSettings.upspeed, dir.Z*buildup)
  438. end
  439. end
  440. end)
  441.  
  442. -- Add Freecam tab to existing Rayfield Window (do not create a new Window)
  443. -- Controls: WASD move, E/Q up/down, Shift sprint, mouse look (RMB if enabled)
  444.  
  445. do
  446. local Workspace = game:GetService("Workspace")
  447. local RunService = game:GetService("RunService")
  448. local UIS = game:GetService("UserInputService")
  449. local Camera = Workspace.CurrentCamera
  450.  
  451. -- State
  452. local Free = {
  453. enabled = false,
  454. speed = 25, -- studs/sec
  455. sprintMult = 3, -- multiplier when holding LeftShift
  456. mouseLookHoldRMB = true,
  457. sensitivity = 0.0025 -- mouse sensitivity
  458. }
  459.  
  460. local savedCam = nil
  461. local fcPos, yaw, pitch = nil, 0, 0
  462. local mouseDelta = Vector2.zero
  463.  
  464. -- Mouse delta capture (only once)
  465. local _icConn = UIS.InputChanged:Connect(function(input)
  466. if not Free.enabled then return end
  467. if input.UserInputType == Enum.UserInputType.MouseMovement then
  468. if (not Free.mouseLookHoldRMB) or UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) then
  469. mouseDelta = input.Delta
  470. else
  471. mouseDelta = Vector2.zero
  472. end
  473. end
  474. end)
  475.  
  476. local function enableFreecam()
  477. if Free.enabled then return end
  478. Free.enabled = true
  479.  
  480. savedCam = {
  481. type = Camera.CameraType,
  482. subject = Camera.CameraSubject,
  483. cframe = Camera.CFrame,
  484. fov = Camera.FieldOfView
  485. }
  486. Camera.CameraType = Enum.CameraType.Scriptable
  487.  
  488. fcPos = Camera.CFrame.Position
  489. local look = Camera.CFrame.LookVector
  490. yaw = math.atan2(look.X, look.Z)
  491. pitch = math.asin(math.clamp(look.Y, -0.999, 0.999))
  492. end
  493.  
  494. local function disableFreecam()
  495. if not Free.enabled then return end
  496. Free.enabled = false
  497. mouseDelta = Vector2.zero
  498. if savedCam then
  499. Camera.CameraType = savedCam.type
  500. Camera.CameraSubject = savedCam.subject
  501. Camera.CFrame = savedCam.cframe
  502. Camera.FieldOfView = savedCam.fov
  503. else
  504. Camera.CameraType = Enum.CameraType.Custom
  505. end
  506. end
  507.  
  508. -- Movement/update (only once)
  509. local _rsConn = RunService.RenderStepped:Connect(function(dt)
  510. if not Free.enabled then return end
  511.  
  512. -- Mouse look
  513. if mouseDelta.Magnitude ~= 0 then
  514. yaw = yaw - mouseDelta.X * Free.sensitivity
  515. pitch = math.clamp(pitch - mouseDelta.Y * Free.sensitivity, -1.55, 1.55)
  516. mouseDelta = Vector2.zero
  517. end
  518.  
  519. local rot = CFrame.Angles(0, yaw, 0) * CFrame.Angles(pitch, 0, 0)
  520. local fwd = rot.LookVector
  521. local right = rot.RightVector
  522. local up = Vector3.yAxis
  523.  
  524. -- Move
  525. local dir = Vector3.zero
  526. if UIS:IsKeyDown(Enum.KeyCode.W) then dir += fwd end
  527. if UIS:IsKeyDown(Enum.KeyCode.S) then dir -= fwd end
  528. if UIS:IsKeyDown(Enum.KeyCode.D) then dir += right end
  529. if UIS:IsKeyDown(Enum.KeyCode.A) then dir -= right end
  530. if UIS:IsKeyDown(Enum.KeyCode.E) then dir += up end
  531. if UIS:IsKeyDown(Enum.KeyCode.Q) then dir -= up end
  532. if dir.Magnitude > 0 then dir = dir.Unit end
  533.  
  534. local speed = Free.speed * (UIS:IsKeyDown(Enum.KeyCode.LeftShift) and Free.sprintMult or 1)
  535. fcPos = fcPos + dir * speed * dt
  536.  
  537. Camera.CFrame = CFrame.new(fcPos) * rot
  538. end)
  539.  
  540. -- Require existing Window
  541. if not Window or type(Window) ~= "table" or not Window.CreateTab then
  542. warn("Freecam tab: expected global 'Window' (Rayfield window) to exist")
  543. return
  544. end
  545.  
  546. -- UI: add Freecam tab
  547. local FreeTab = Window:CreateTab("Freecam")
  548.  
  549. FreeTab:CreateToggle({
  550. Name = "Freecam enabled",
  551. CurrentValue = false,
  552. Callback = function(v)
  553. if v then enableFreecam() else disableFreecam() end
  554. end
  555. })
  556.  
  557. FreeTab:CreateSlider({
  558. Name = "Speed",
  559. Range = {5, 300},
  560. Increment = 1,
  561. CurrentValue = Free.speed,
  562. Suffix = "st/s",
  563. Callback = function(val) Free.speed = math.floor(val) end
  564. })
  565.  
  566. FreeTab:CreateSlider({
  567. Name = "Sprint multiplier (Shift)",
  568. Range = {1, 10},
  569. Increment = 0.5,
  570. CurrentValue = Free.sprintMult,
  571. Callback = function(val) Free.sprintMult = val end
  572. })
  573.  
  574. FreeTab:CreateToggle({
  575. Name = "Mouse look only on RMB",
  576. CurrentValue = Free.mouseLookHoldRMB,
  577. Callback = function(v) Free.mouseLookHoldRMB = v end
  578. })
  579.  
  580. FreeTab:CreateSlider({
  581. Name = "Mouse sensitivity",
  582. Range = {0.0005, 0.01},
  583. Increment = 0.0005,
  584. CurrentValue = Free.sensitivity,
  585. Callback = function(val) Free.sensitivity = val end
  586. })
  587.  
  588. FreeTab:CreateKeybind({
  589. Name = "Toggle Freecam (keybind)",
  590. CurrentKeybind = "F",
  591. HoldToInteract = false,
  592. Callback = function()
  593. if Free.enabled then disableFreecam() else enableFreecam() end
  594. end
  595. })
  596.  
  597. -- Optional: expose quick API
  598. _G.FreecamTab = {
  599. Enable = enableFreecam,
  600. Disable = disableFreecam,
  601. IsEnabled = function() return Free.enabled end,
  602. SetSpeed = function(v) Free.speed = v end,
  603. SetSprintMult = function(v) Free.sprintMult = v end,
  604. SetSensitivity = function(v) Free.sensitivity = v end
  605. }
  606. end
  607.  
  608. -- ========== загрузка конфигурации ==========
  609. pcall(function()
  610. Rayfield:LoadConfiguration()
  611. task.defer(function()
  612. applyVisualToAll()
  613. rescanHeads()
  614. end)
  615. end)
RAW Paste Data Copied