Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I return the X position of the mouse inside 2D for GUIs?

local s = workspace.Part.Sound
local p = game.Players.LocalPlayer
local m = p:GetMouse()



script.Parent.Frame.Frame.MouseEnter:Connect(function()
	 Inside = true
end)

script.Parent.Frame.Frame.MouseLeave:Connect(function()
	 Inside = false
end)
m.Button1Down:Connect(function()
	if Inside == true then
		script.Parent.Frame.Frame.Size = UDim2.new(m.X, 0, 1,0)
	end
end)


I'm trying to make it so, where you click, the frame will be that size, like on youtube when changing the time on a video.

1 answer

What you can do instead actually is use .MouseButton1Down event and a gui button, which will make this code simpler and actually has a useful feature where its paramaters are the X and Y coordinates of the mouse when it clicked.

button.MouseButton1Down:Connect(function(x, y)
	print("Mouse coords: ", x, y)
end)

And even what you did is right, maybe I didn't understand your question.

This discussion is preserved as it was. New answers, comments, and votes are closed.