-- Services and Variables local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local Player = Players.LocalPlayer local PlayerGui = Player:WaitForChild("PlayerGui") -- IMPORTANT: Define the path to your 'Coins' Value instance inside leaderstats. local Leaderstats = Player:WaitForChild("leaderstats") local COINS_VALUE_INSTANCE = Leaderstats:WaitForChild("Coins") -- GUI Configuration local FRAME_COLOR = Color3.fromRGB(255, 204, 0) -- Gold/Yellow frame local BUTTON_COLOR = Color3.fromRGB(0, 153, 255) -- Bright Blue button local FONT_COLOR = Color3.new(0, 0, 0) -- Black text local FONT_STYLE = Enum.Font.Cartoon local FRAME_SIZE = UDim2.new(0.25, 0, 0.2, 0) -- 25% width, 20% height -- ==================================================================== -- GUI CREATION -- ==================================================================== local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "CoinSetterUI" ScreenGui.Parent = PlayerGui local MainFrame = Instance.new("Frame") MainFrame.Name = "CoinSetterFrame" MainFrame.Size = FRAME_SIZE MainFrame.Position = UDim2.new(0.7, 0, 0.1, 0) MainFrame.BackgroundColor3 = FRAME_COLOR MainFrame.BorderSizePixel = 0 MainFrame.Parent = ScreenGui -- Corner for Frame local FrameCorner = Instance.new("UICorner") FrameCorner.CornerRadius = UDim.new(0, 15) FrameCorner.Parent = MainFrame -- Title/Drag Handle local DragHandle = Instance.new("TextLabel") DragHandle.Name = "DragHandle" DragHandle.Size = UDim2.new(1, 0, 0.25, 0) DragHandle.Position = UDim2.new(0, 0, 0, 0) DragHandle.BackgroundColor3 = FRAME_COLOR DragHandle.BackgroundTransparency = 0.2 DragHandle.Text = "SET COINS" DragHandle.Font = FONT_STYLE DragHandle.TextSize = 20 DragHandle.TextColor3 = FONT_COLOR DragHandle.Parent = MainFrame -- Input TextBox (CORRECTED POSITION) local CoinInput = Instance.new("TextBox") CoinInput.Name = "CoinInput" CoinInput.Size = UDim2.new(0.9, 0, 0.3, 0) CoinInput.Position = UDim2.new(0.5, 0, 0.3, 0) -- Adjusted from 0.45 to 0.3 CoinInput.AnchorPoint = Vector2.new(0.5, 0) CoinInput.PlaceholderText = "Enter new Coin amount..." CoinInput.Font = FONT_STYLE CoinInput.TextSize = 18 CoinInput.TextColor3 = FONT_COLOR CoinInput.BackgroundColor3 = Color3.new(1, 1, 1) CoinInput.BorderSizePixel = 0 CoinInput.ClearTextOnFocus = true CoinInput.Parent = MainFrame local InputCorner = Instance.new("UICorner") InputCorner.CornerRadius = UDim.new(0, 8) InputCorner.Parent = CoinInput -- Set Value Button local SetButton = Instance.new("TextButton") SetButton.Name = "SetButton" SetButton.Size = UDim2.new(0.9, 0, 0.25, 0) SetButton.Position = UDim2.new(0.5, 0, 0.8, 0) SetButton.AnchorPoint = Vector2.new(0.5, 1) SetButton.Text = "SET VALUE" SetButton.Font = FONT_STYLE SetButton.TextSize = 22 SetButton.TextColor3 = Color3.new(1, 1, 1) SetButton.BackgroundColor3 = BUTTON_COLOR SetButton.BorderSizePixel = 0 SetButton.Parent = MainFrame local ButtonCorner = Instance.new("UICorner") ButtonCorner.CornerRadius = UDim.new(0, 8) ButtonCorner.Parent = SetButton -- ==================================================================== -- FUNCTIONAL LOGIC -- ==================================================================== local function setValue() local text = CoinInput.Text local numberValue = tonumber(text) if numberValue ~= nil then if COINS_VALUE_INSTANCE and COINS_VALUE_INSTANCE:IsA("ValueBase") then COINS_VALUE_INSTANCE.Value = numberValue SetButton.Text = "SET! (" .. numberValue .. ")" task.wait(0.5) SetButton.Text = "SET VALUE" else warn("Coins Value instance not found or is not a ValueBase!") end else SetButton.Text = "INVALID NUMBER!" task.wait(1) SetButton.Text = "SET VALUE" end end SetButton.MouseButton1Click:Connect(setValue) -- ==================================================================== -- DRAGGABLE FRAME LOGIC -- ==================================================================== local dragging = false local dragOffset = Vector2.zero local function handleInputBegan(input) if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) and input.Target == DragHandle then dragging = true local framePosition = MainFrame.AbsolutePosition dragOffset = input.Position - framePosition end end local function handleInputChanged(input) if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then local newPos = input.Position - dragOffset MainFrame.Position = UDim2.fromOffset(newPos.X, newPos.Y) end end local function handleInputEnded(input) if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) and dragging then dragging = false dragOffset = Vector2.zero end end -- Connect the drag logic UserInputService.InputBegan:Connect(handleInputBegan) UserInputService.InputChanged:Connect(handleInputChanged) UserInputService.InputEnded:Connect(handleInputEnded) print("Coin Setter UI Initialized and connected to leaderstats.")