Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local UserInputService = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local Workspace = game:GetService("Workspace")
- local player = Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local rootPart = character:FindFirstChild("HumanoidRootPart")
- local gravityEnabled = false
- local objects = {}
- -- Tworzenie GUI
- local function createGui()
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "GravityToggleGui"
- screenGui.ResetOnSpawn = false
- screenGui.Parent = player:WaitForChild("PlayerGui")
- local toggleButton = Instance.new("TextButton")
- toggleButton.Size = UDim2.new(0, 50, 0, 50)
- toggleButton.Position = UDim2.new(0, 10, 1, -60) -- Lewy dolny róg
- toggleButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- toggleButton.BorderSizePixel = 0
- toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- toggleButton.TextSize = 30
- toggleButton.Text = "X"
- toggleButton.Parent = screenGui
- local function updateButton()
- toggleButton.BackgroundColor3 = gravityEnabled and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
- end
- local function toggleGravity()
- gravityEnabled = not gravityEnabled
- updateButton()
- if gravityEnabled then
- -- Pobranie wszystkich części w grze
- for _, part in pairs(Workspace:GetDescendants()) do
- if part:IsA("BasePart") and not part:IsDescendantOf(player.Character) and not part.Anchored then
- table.insert(objects, part)
- end
- end
- else
- -- Resetowanie obiektów na ziemię
- for _, part in ipairs(objects) do
- if part then
- part.Velocity = Vector3.new(0, 0, 0)
- end
- end
- objects = {}
- end
- end
- toggleButton.MouseButton1Click:Connect(toggleGravity)
- UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if not gameProcessed and input.KeyCode == Enum.KeyCode.X then
- toggleGravity()
- end
- end)
- updateButton()
- end
- createGui()
- -- Funkcja do aktualizacji pozycji obiektów
- RunService.RenderStepped:Connect(function()
- if gravityEnabled and rootPart then
- local angle = 0
- local radius = 10 -- Promień okręgu
- for _, part in ipairs(objects) do
- if part then
- local offsetX = math.cos(angle) * radius
- local offsetZ = math.sin(angle) * radius
- local targetPosition = rootPart.Position + Vector3.new(offsetX, 10, offsetZ)
- part.Velocity = (targetPosition - part.Position) * 5
- angle = angle + (math.pi * 2) / #objects
- end
- end
- end
- end)
- Players.LocalPlayer.CharacterAdded:Connect(function()
- if not player.PlayerGui:FindFirstChild("GravityToggleGui") then
- createGui()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment