So i tried searching the wiki trying to figure this out but i cant find anything. Basically i am making an rbg color creator for random reasons And i dont want it to drag out side the frame so i am making and if statement that checks if the position is grater than the udim.

player = game.Players.LocalPlayer
mouse = player:GetMouse()

dragging = false

function drag()
	while dragging == true do
	
		if script.Parent.Position >= UDim2.new(0,255,0,0) then
			print(34)
		end
		script.Parent.Position = UDim2.new(0,mouse.X - 225,0,0)
--[[^^^^^^^^^^^^^^^^^^dont worry about this i set it up so it puts the gui on the mouse]]		
		wait()
	end
end

script.Parent.DragBegin:connect(function()
	dragging = true
	drag()
end)

script.Parent.DragStopped:connect(function()
	dragging = fals
end)

3 comments

0

ik that much but im trying to make it to were is dose not go out side a frame

0

Use AbsolutePosition and AbsoluteSize to compare Gui objects.