Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Stop A TextButton From Dragging Down Too Much?

Asked by 5 years ago

I have this script where I have a TextButton that is dragged down whenever a player's mouse is dragged down. I want it so that it won't keep going down to the player's screen, and stop at a specific UDim2 position. How would I go about doing that?

Code:

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Button = script.Parent
local Change = 0.04210526315
local hold = false

Button.MouseButton1Down:Connect(function()
    local startPos = Button.Position
    local endPos = UDim2.new(0,0,0.8,0)
        Button.MouseMoved:Connect(function()
        if startPos ~= endPos then
            Button.Position = Button.Position + UDim2.new(0, 0, Change, 0)
        elseif startPos == endPos then
            Button.Position = endPos
        end
    end)
end)
0
don't know if you realize this but the change will never equal exactly 0.8 :| aandmprogameing 52 — 5y
0
i mean when i look at the properties tab it rounds to 0.8 lol LukeGabrieI 73 — 5y

Answer this question