Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Get the player
- local player = game.Players.LocalPlayer
- -- Create GUI
- local gui = Instance.new("ScreenGui", player.PlayerGui)
- gui.ResetOnSpawn = false
- -- Create Frame
- local frame = Instance.new("Frame", gui)
- frame.Size = UDim2.new(0, 120, 0, 180)
- frame.Position = UDim2.new(0.5, -60, 0.5, -90)
- frame.BackgroundColor3 = Color3.fromRGB(125, 255, 255)
- frame.Active, frame.Draggable = true, true
- -- Create Buttons/Inputs
- local function createButton(text, pos, color, parent, size)
- local btn = Instance.new("TextButton", parent)
- btn.Size = size or UDim2.new(0, 100, 0, 30)
- btn.Position = pos
- btn.BackgroundColor3 = color
- btn.Text = text
- btn.TextScaled = true
- return btn
- end
- local function createTextbox(pos, parent)
- local box = Instance.new("TextBox", parent)
- box.Size = UDim2.new(0, 100, 0, 30)
- box.Position = pos
- box.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- box.PlaceholderText = "hp%"
- box.Text = ""
- box.TextScaled = true
- return box
- end
- -- UI Elements
- local inputBox = createTextbox(UDim2.new(0.5, -50, 0.3, 0), frame)
- local toggleButton = createButton("เปิด", UDim2.new(0.5, -50, 0.55, 0), Color3.fromRGB(255, 255, 255), frame)
- local minimizeButton = createButton("ย่อเมนู", UDim2.new(0.5, -50, 0.8, 0), Color3.fromRGB(255, 0, 0), frame)
- local openButton = createButton("เปิด", UDim2.new(0.02, 0, 0.02, 0), Color3.fromRGB(125, 255, 125), gui, UDim2.new(0, 50, 0, 30))
- openButton.Visible = false
- -- Toggle loop logic
- local running = false
- toggleButton.MouseButton1Click:Connect(function()
- running = not running
- toggleButton.Text = running and "ปิด" or "เปิด"
- if running then
- task.spawn(function()
- while running do
- local inputValue = tonumber(inputBox.Text) or 0
- local threshold = (inputValue <= 0) and 0.9999 or (inputValue / 100)
- sethiddenproperty(player, "SimulationRadius", math.huge)
- sethiddenproperty(player, "MaxSimulationRadius", math.huge)
- for _, d in pairs(workspace:GetDescendants()) do
- if d:IsA("Humanoid") and d.Parent.Name ~= player.Name then
- if d.Health <= (d.MaxHealth * threshold) then
- d.Health = 0
- end
- end
- end
- task.wait(0.1)
- end
- end)
- end
- end)
- -- Minimize/Maximize
- minimizeButton.MouseButton1Click:Connect(function()
- frame.Visible = false
- openButton.Visible = true
- end)
- openButton.MouseButton1Click:Connect(function()
- frame.Visible = true
- openButton.Visible = false
- end)
- -- Drag support
- local function enableDragging(guiElement)
- local dragging, dragInput, mousePos, framePos
- guiElement.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- mousePos = input.Position
- framePos = guiElement.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end)
- guiElement.InputChanged:Connect(function(input)
- if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
- local delta = input.Position - mousePos
- guiElement.Position = UDim2.new(
- framePos.X.Scale, framePos.X.Offset + delta.X,
- framePos.Y.Scale, framePos.Y.Offset + delta.Y
- )
- end
- end)
- end
- enableDragging(frame)
- enableDragging(openButton)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement