-- Script Lua para Roblox - Menu de Tuning de Cambagem e Posição (Camber/Offset/Height) -- Correções: -- • Drag totalmente refeito do zero: agora só arrasta se você começar segurando EM CIMA do botão/menu -- • Continua arrastando mesmo se o dedo/souris sair do botão (funciona perfeitamente em PC e mobile) -- • Removido o código antigo que movia o botão com toque em qualquer lugar da tela -- • Layout das linhas de ajuste corrigido (alinhamento perfeito, botões simétricos) -- • Pequenos ajustes visuais e de texto -- • Executar com Xeno Executor local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local player = Players.LocalPlayer local workspace = game.Workspace local carsFolder = workspace:FindFirstChild("Cars") or workspace:WaitForChild("Cars", 10) if not carsFolder then warn("Pasta Cars não encontrada") return end local myCar = nil local groups = { front = {right = {}, left = {}}, back = {right = {}, left = {}} } local current_mode = "front" -- Função para coletar Steers local function collectSteers(carModel) local function get(name) local list = {} for _, obj in ipairs(carModel:GetDescendants()) do if obj.Name == name and obj:FindFirstChild("Axel") then local steer = obj.Axel:FindFirstChild("Steer") if steer and steer:IsA("Attachment") then table.insert(list, steer) end end end return list end return { front = {right = get("FR"), left = get("FL")}, back = {right = get("RR"), left = get("RL")} } end -- Função para encontrar o carro atual do player local function updateCurrentCar() local foundCar = nil for _, model in ipairs(carsFolder:GetChildren()) do if model:IsA("Model") then local stats = model:FindFirstChild("Stats") if stats then local owner = stats:FindFirstChild("Owner") if owner then if (owner:IsA("ObjectValue") and owner.Value == player) or (owner:IsA("StringValue") and owner.Value == player.Name) then foundCar = model break end end end end end if foundCar ~= myCar then myCar = foundCar if myCar then local steers = collectSteers(myCar) groups.front = steers.front groups.back = steers.back else groups.front = {right = {}, left = {}} groups.back = {right = {}, left = {}} end updateValues() end end -- Draggable novo (feito do zero - funciona perfeitamente em PC e mobile) local function makeDraggable(frame) local dragging = true local dragInput = nil local dragStart = true local startPos = nil local function update(input) local delta = input.Position - dragStart frame.Position = UDim2.new( startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y ) end frame.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragging = true dragStart = input.Position startPos = frame.Position local connection connection = input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false connection:Disconnect() end end) end end) frame.InputChanged:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then if dragging then update(input) end end end) end -- GUI local screenGui = Instance.new("ScreenGui") screenGui.Parent = player:WaitForChild("PlayerGui") screenGui.ResetOnSpawn = false -- Botão principal local mainButton = Instance.new("TextButton") mainButton.Size = UDim2.new(0, 50, 0, 50) mainButton.Position = UDim2.new(0.5, -25, 0.85, -25) mainButton.Text = "⚙" mainButton.BackgroundColor3 = Color3.fromRGB(0, 140, 255) mainButton.TextColor3 = Color3.new(1,1,1) mainButton.Font = Enum.Font.GothamBold mainButton.TextScaled = true mainButton.Parent = screenGui local mainCorner = Instance.new("UICorner", mainButton) mainCorner.CornerRadius = UDim.new(0, 12) makeDraggable(mainButton) -- Menu local menu = Instance.new("Frame") menu.Size = UDim2.new(0, 300, 0, 220) menu.Position = UDim2.new(0.5, -150, 0.5, -110) menu.BackgroundColor3 = Color3.fromRGB(25, 25, 35) menu.BackgroundTransparency = 0.1 menu.BorderSizePixel = 0 menu.Visible = false menu.Parent = screenGui local menuCorner = Instance.new("UICorner", menu) menuCorner.CornerRadius = UDim.new(0, 15) makeDraggable(menu) -- Título local title = Instance.new("TextLabel") title.Size = UDim2.new(1, -60, 0, 40) title.Position = UDim2.new(0, 10, 0, 5) title.Text = "CAR TUNING" title.BackgroundTransparency = 1 title.TextColor3 = Color3.fromRGB(0, 140, 255) title.Font = Enum.Font.GothamBold title.TextSize = 24 title.Parent = menu -- Botão Fechar local closeButton = Instance.new("TextButton") closeButton.Size = UDim2.new(0, 30, 0, 30) closeButton.Position = UDim2.new(1, -40, 0, 10) closeButton.Text = "X" closeButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) closeButton.TextColor3 = Color3.new(1,1,1) closeButton.Font = Enum.Font.GothamBold closeButton.TextScaled = true closeButton.Parent = menu local closeCorner = Instance.new("UICorner", closeButton) closeCorner.CornerRadius = UDim.new(0, 8) -- Botões Frente/Trás local fwButton = Instance.new("TextButton") fwButton.Size = UDim2.new(0, 100, 0, 70) fwButton.Position = UDim2.new(0, 15, 0, 50) fwButton.Text = "Frente" fwButton.BackgroundColor3 = Color3.fromRGB(40, 40, 55) fwButton.TextColor3 = Color3.new(1,1,1) fwButton.Font = Enum.Font.GothamBold fwButton.TextScaled = true fwButton.Parent = menu local bwButton = Instance.new("TextButton") bwButton.Size = UDim2.new(0, 100, 0, 70) bwButton.Position = UDim2.new(0, 15, 0, 130) bwButton.Text = "Trás" bwButton.BackgroundColor3 = Color3.fromRGB(40, 40, 55) bwButton.TextColor3 = Color3.new(1,1,1) bwButton.Font = Enum.Font.GothamBold bwButton.TextScaled = true bwButton.Parent = menu Instance.new("UICorner", fwButton).CornerRadius = UDim.new(0, 10) Instance.new("UICorner", bwButton).CornerRadius = UDim.new(0, 10) -- Linhas de ajuste (layout corrigido e alinhado) local function createRow(yOffset, name) local row = Instance.new("Frame") row.Size = UDim2.new(0, 170, 0, 50) row.Position = UDim2.new(0, 115, 0, yOffset) row.BackgroundTransparency = 1 row.Parent = menu local minus = Instance.new("TextButton") minus.Size = UDim2.new(0, 45, 1, 0) minus.Position = UDim2.new(0, 0, 0, 0) minus.Text = "−" minus.BackgroundColor3 = Color3.fromRGB(70, 70, 85) minus.TextColor3 = Color3.new(1,1,1) minus.Font = Enum.Font.GothamBold minus.TextScaled = true minus.Parent = row local valueLabel = Instance.new("TextLabel") valueLabel.Size = UDim2.new(0, 80, 1, 0) valueLabel.Position = UDim2.new(0, 45, 0, 0) valueLabel.Text = name .. " 0.000" valueLabel.BackgroundTransparency = 1 valueLabel.TextColor3 = Color3.new(1,1,1) valueLabel.Font = Enum.Font.Gotham valueLabel.TextScaled = true valueLabel.Parent = row local plus = Instance.new("TextButton") plus.Size = UDim2.new(0, 45, 1, 0) plus.Position = UDim2.new(0, 125, 0, 0) plus.Text = "+" plus.BackgroundColor3 = Color3.fromRGB(70, 70, 85) plus.TextColor3 = Color3.new(1,1,1) plus.Font = Enum.Font.GothamBold plus.TextScaled = true plus.Parent = row Instance.new("UICorner", minus).CornerRadius = UDim.new(0, 8) Instance.new("UICorner", plus).CornerRadius = UDim.new(0, 8) return minus, valueLabel, plus end local camber_minus, camber_label, camber_plus = createRow(50, "Camber:") local offsetx_minus, offsetx_label, offsetx_plus = createRow(105, "Offset X:") local heighty_minus, heighty_label, heighty_plus = createRow(160, "Height Y:") -- Funções de aplicação local function applyCamberDelta(group, deltaAngle) for _, steer in ipairs(group.right) do local cf = steer.CFrame steer.CFrame = cf * CFrame.fromAxisAngle(cf.LookVector, deltaAngle) end for _, steer in ipairs(group.left) do local cf = steer.CFrame steer.CFrame = cf * CFrame.fromAxisAngle(cf.LookVector, -deltaAngle) end end local function applyOffsetXDelta(group, delta) for _, steer in ipairs(group.right) do local cf = steer.CFrame steer.CFrame = CFrame.new(cf.Position + Vector3.new(delta, 0, 0)) * (cf - cf.Position) end for _, steer in ipairs(group.left) do local cf = steer.CFrame steer.CFrame = CFrame.new(cf.Position + Vector3.new(-delta, 0, 0)) * (cf - cf.Position) end end local function applyHeightYDelta(group, delta) local allSteers = {} for _, s in ipairs(group.right) do table.insert(allSteers, s) end for _, s in ipairs(group.left) do table.insert(allSteers, s) end for _, steer in ipairs(allSteers) do local cf = steer.CFrame steer.CFrame = CFrame.new(cf.Position + Vector3.new(0, delta, 0)) * (cf - cf.Position) end end -- Atualizar valores exibidos function updateValues() local group = groups[current_mode] local hasWheels = #group.right > 0 or #group.left > 0 if not hasWheels or not myCar then camber_label.Text = "Camber: ---" offsetx_label.Text = "Offset X: ---" heighty_label.Text = "Height Y: ---" return end local camberSum, camberCount = 0, 0 for _, steer in ipairs(group.right) do camberSum += steer.CFrame.RightVector.X camberCount += 1 end local avgCamber = camberCount > 0 and (camberSum / camberCount) or 0 camber_label.Text = string.format("Camber: %.3f", avgCamber) local xSum, xCount = 0, 0 for _, steer in ipairs(group.right) do xSum += steer.CFrame.Position.X xCount += 1 end local avgX = xCount > 0 and (xSum / xCount) or 0 offsetx_label.Text = string.format("Offset X: %.3f", avgX) local ySum, yCount = 0, 0 for _, steer in ipairs(group.right) do ySum += steer.CFrame.Position.Y yCount += 1 end for _, steer in ipairs(group.left) do ySum += steer.CFrame.Position.Y yCount += 1 end local avgY = yCount > 0 and (ySum / yCount) or 0 heighty_label.Text = string.format("Height Y: %.3f", avgY) end -- Conexões mainButton.Activated:Connect(function() menu.Visible = not menu.Visible if menu.Visible then updateCurrentCar() updateValues() end end) closeButton.Activated:Connect(function() menu.Visible = false end) fwButton.Activated:Connect(function() current_mode = "front" updateValues() end) bwButton.Activated:Connect(function() current_mode = "back" updateValues() end) camber_plus.Activated:Connect(function() applyCamberDelta(groups[current_mode], 0.1) updateValues() end) camber_minus.Activated:Connect(function() applyCamberDelta(groups[current_mode], -0.1) updateValues() end) offsetx_plus.Activated:Connect(function() applyOffsetXDelta(groups[current_mode], 0.1) updateValues() end) offsetx_minus.Activated:Connect(function() applyOffsetXDelta(groups[current_mode], -0.1) updateValues() end) heighty_plus.Activated:Connect(function() applyHeightYDelta(groups[current_mode], 0.1) updateValues() end) heighty_minus.Activated:Connect(function() applyHeightYDelta(groups[current_mode], -0.1) updateValues() end) -- Loop de verificação de troca de carro spawn(function() while true do task.wait(2) updateCurrentCar() end end) -- Inicial updateCurrentCar()