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)

2 comments

0

don't know if you realize this but the change will never equal exactly 0.8 :|

0

i mean when i look at the properties tab it rounds to 0.8 lol