Line connecting 2 gui resizing problem

I’m sorry, im not into maths in roblox studio so how do I put that in my script?, I haven’t tried math because I thought its gonna be alot of solving which is what I hate

Start off by changing wireStart to be wire.AbsolutePosition + Vector2.new(wire.AbsoluteSize.X, wire.AbsoluteSize.Y / 2) and see where that gets you.

OHH, it works now, TY FOR YOUR HELPP @7z99 :grin:

1 Like

I still have this problem tho


if im gonna connect it to another gui and not the mouse it do this

local mouse = script.Parent.Parent.RedConnector.Position
local wire = script.Parent.Parent.RedWireStart
local wireStart = wire.AbsolutePosition + Vector2.new(wire.AbsoluteSize.X, wire.AbsoluteSize.Y / 2) --absolute position in pixels

while wait() do

	local mousePos = Vector2.new(mouse.X,mouse.Y)
	local v = mousePos-wireStart
	local angle = math.deg(math.atan2(v.Y,v.X))

	script.Parent.Rotation = angle

	script.Parent.Size = UDim2.new(0,(mousePos - wireStart).Magnitude,0,20)
	
	local centrePoint = (wireStart + mousePos) / 2 -- this will be the "average" position which also happens to be the centre of the two points
	
	script.Parent.Parent.RedConnector.Rotation = script.Parent.Rotation
	
	script.Parent.Position = UDim2.fromOffset(centrePoint.X - script.Parent.Parent.AbsolutePosition.X, centrePoint.Y - script.Parent.Parent.AbsolutePosition.Y)
	
end

did I do something wrong with the script?
changing the position to AbsolutePosition kinda help the size but the wire doesn’t change the length anymore
image
image

I’m looking over your script but nothing really sticks out. Are there any output errors? Also just to be clear, it’s the script’s parent that you need to resize, right?

1 Like

yes, its the scripts parent I wanted to resize, and no, theres no errors, I think its the while loop thats not working properly

1 Like

Try setting the AnchorPoint property of the frame that needs to be resized to 0.5, 0.5

most all of my gui anchor points are 0.5,0.5 so the position will be the same on all devices, also, I found out that the thickness of line is based on offset which will be brocken on other sizes of screens
image
this is what it looks like on mobile

I’m a bit confused now, is the wire resizing?

And for consistent sizing on all devices, just change the size from UDim2.new(0,magnitude,0,20) to 0,magnitude,scale y,0

its resizing an constantly changing position

Wait, that isn’t what you wanted to do?

I wanted it to do that but is there a way to make the end point a gui and not the mouse?, if none ill try to find a way to do it

Ohhhh I must have skipped over when you asked that, I’m looking back now and you said that in the 13th post :man_facepalming:, my bad.

Yeah, you can do that. Just change mousePos to be the end frame’s AbsolutePosition instead of the mouse.X and mouse.Y.

im a bit confused on this, do i need to do UDim2.new, UDim2.fromScale, or UDim2.fromOffset?

You’d use UDim2.new, the first number can stay 0, second is the magnitude of the one vector subtracted from the other, scale y would be the Y scale from your start or end frames assuming you want the size to remain the same, and the fourth number can stay as 0.

1 Like

it becomes as thin as you cant see it anymore
image
image
is this correct?
script.Parent.Size = UDim2.new(0,(mousePos - wireStart).Magnitude,script.Parent.Parent.RedWireStart.Size.Y,0)

update:
nvm, I just input the number by myself and not use a lot of letters to go to the start and get the Y size

1 Like

local mousePos = script.Parent.Parent.RedConnector.AbsolutePosition
is this what you mean’t?, after 25 post in my topic I still dont want to learn math in roblxo studio lol

Yeah, that is what I meant. (chars)

1 Like

image
I does this, also when I used visible its of the draggable part and I dont realyl want that to happen since I want my game to be perfect and not fix it after uploading it

Can you upload a repro file? It’s a bit hard to tell what’s going on.