Lay button
Key RequiredUniversal

Lay button

Universal ScriptCadhounCadhoun 7.3K views 1.8K executesUpdated Oct 29, 2024
Unrated
00
Lua Script•95 lines (3643 chars)
local player = game.Players.LocalPlayer
local screenGui = Instance.new("ScreenGui")
screenGui.ResetOnSpawn = false -- Asegura que la interfaz no se reinicie con el personaje
screenGui.Parent = player:WaitForChild("PlayerGui")

-- Botón "Lay"
local layButton = Instance.new("TextButton")
layButton.Size = UDim2.new(0.05, 0, 0.05, 0) -- Tamaño pequeño
layButton.Position = UDim2.new(0.4, 0, 0.4, 0)
layButton.Text = "Lay"
layButton.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5) -- Gris
layButton.BackgroundTransparency = 0.48 -- 48% transparente
layButton.Parent = screenGui

-- Variable para rastrear si el personaje está acostado
local isLaying = false

-- Función para alternar entre acostarse y regresar a la posición normal
layButton.MouseButton1Click:Connect(function()
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    local rootPart = character:FindFirstChild("HumanoidRootPart")

    if humanoid and rootPart then
        if isLaying then
            -- Volver a la posición normal
            humanoid.PlatformStand = false
            rootPart.CFrame = rootPart.CFrame * CFrame.Angles(math.rad(-90), 0, 0) -- Revertir la rotación
            isLaying = false
        else
            -- Acostarse
            humanoid.PlatformStand = true
            rootPart.CFrame = rootPart.CFrame * CFrame.Angles(math.rad(90), 0, 0) -- Acostar al personaje
            isLaying = true
        end
    end
end)

-- Botón "Remove"
local removeButton = Instance.new("TextButton")
removeButton.Size = UDim2.new(0.05, 0, 0.05, 0) -- Tamaño pequeño
removeButton.Position = UDim2.new(0.45, 0, 0.4, 0) -- Junto al botón "Lay"
removeButton.Text = "Remove"
removeButton.BackgroundColor3 = Color3.new(1, 0, 0) -- Rojo
removeButton.BackgroundTransparency = 0.48 -- 48% transparente
removeButton.Parent = screenGui

-- Función para quitar la interfaz
removeButton.MouseButton1Click:Connect(function()
    screenGui:Destroy() -- Quita la interfaz
end)

-- Hacer que los botones sean movibles
local dragging = false
local dragStart = nil
local startPos = nil

local function updateButtonPosition(input)
    local delta = input.Position - dragStart
    local newPosition = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)

    -- Actualiza la posición del botón "Lay"
    layButton.Position = newPosition
    -- Actualiza la posición del botón "Remove" basado en la posición del botón "Lay"
    removeButton.Position = UDim2.new(newPosition.X.Scale + 0.05, newPosition.X.Offset, newPosition.Y.Scale, newPosition.Y.Offset)
end

local function startDragging(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        dragging = true
        dragStart = input.Position
        startPos = layButton.Position

        input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then
                dragging = false
            end
        end)
    end
end

layButton.InputBegan:Connect(startDragging)
removeButton.InputBegan:Connect(startDragging)

layButton.InputChanged:Connect(function(input)
    if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
        updateButtonPosition(input)
    end
end)

removeButton.InputChanged:Connect(function(input)
    if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
        updateButtonPosition(input)
    end
end)

Features & Information

Nothing, u can just lay

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts