Nythic

Untitled

Mar 9th, 2025
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local UserInputService = game:GetService("UserInputService")
  3. local RunService = game:GetService("RunService")
  4. local Workspace = game:GetService("Workspace")
  5.  
  6. local player = Players.LocalPlayer
  7. local character = player.Character or player.CharacterAdded:Wait()
  8. local rootPart = character:FindFirstChild("HumanoidRootPart")
  9.  
  10. local gravityEnabled = false
  11. local objects = {}
  12.  
  13. -- Tworzenie GUI
  14. local function createGui()
  15. local screenGui = Instance.new("ScreenGui")
  16. screenGui.Name = "GravityToggleGui"
  17. screenGui.ResetOnSpawn = false
  18. screenGui.Parent = player:WaitForChild("PlayerGui")
  19.  
  20. local toggleButton = Instance.new("TextButton")
  21. toggleButton.Size = UDim2.new(0, 50, 0, 50)
  22. toggleButton.Position = UDim2.new(0, 10, 1, -60) -- Lewy dolny róg
  23. toggleButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  24. toggleButton.BorderSizePixel = 0
  25. toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  26. toggleButton.TextSize = 30
  27. toggleButton.Text = "X"
  28. toggleButton.Parent = screenGui
  29.  
  30. local function updateButton()
  31. toggleButton.BackgroundColor3 = gravityEnabled and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
  32. end
  33.  
  34. local function toggleGravity()
  35. gravityEnabled = not gravityEnabled
  36. updateButton()
  37.  
  38. if gravityEnabled then
  39. -- Pobranie wszystkich części w grze
  40. for _, part in pairs(Workspace:GetDescendants()) do
  41. if part:IsA("BasePart") and not part:IsDescendantOf(player.Character) and not part.Anchored then
  42. table.insert(objects, part)
  43. end
  44. end
  45. else
  46. -- Resetowanie obiektów na ziemię
  47. for _, part in ipairs(objects) do
  48. if part then
  49. part.Velocity = Vector3.new(0, 0, 0)
  50. end
  51. end
  52. objects = {}
  53. end
  54. end
  55.  
  56. toggleButton.MouseButton1Click:Connect(toggleGravity)
  57.  
  58. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  59. if not gameProcessed and input.KeyCode == Enum.KeyCode.X then
  60. toggleGravity()
  61. end
  62. end)
  63.  
  64. updateButton()
  65. end
  66.  
  67. createGui()
  68.  
  69. -- Funkcja do aktualizacji pozycji obiektów
  70. RunService.RenderStepped:Connect(function()
  71. if gravityEnabled and rootPart then
  72. local angle = 0
  73. local radius = 10 -- Promień okręgu
  74.  
  75. for _, part in ipairs(objects) do
  76. if part then
  77. local offsetX = math.cos(angle) * radius
  78. local offsetZ = math.sin(angle) * radius
  79. local targetPosition = rootPart.Position + Vector3.new(offsetX, 10, offsetZ)
  80.  
  81. part.Velocity = (targetPosition - part.Position) * 5
  82. angle = angle + (math.pi * 2) / #objects
  83. end
  84. end
  85. end
  86. end)
  87.  
  88. Players.LocalPlayer.CharacterAdded:Connect(function()
  89. if not player.PlayerGui:FindFirstChild("GravityToggleGui") then
  90. createGui()
  91. end
  92. end)
  93.  
Tags: grav
Advertisement
Add Comment
Please, Sign In to add comment