Scripting a wire task like Among Us

Currently I have this GUI as a base,

(not the most beautiful GUI I know)

and I want to be able to connect these wires like how it is in Among Us. Problem is:

This happens. I know the problem here, I need to map this scale between each sides of my inside frame but I couldn’t think a way of doing that. Here is the related part of my script:

runServiceEvent = runService.RenderStepped:Connect(function()
		if holding then
			local frameCenter = copy.AbsolutePosition + (copy.AbsoluteSize/2)
			local x = math.atan2(mouse.Y - frameCenter.Y, mouse.X - frameCenter.X)
			copy.Rotation = math.deg(x)
			copy.Size = + originalSize, 0, copy.Size.Y.Scale, 0)
1 Like

The Video isn’t working, I don’t get ur mistake sorry.

1 Like

As stated above me, your video doesn’t work, so it’s hard to tell what exactly doesn’t work.

I recommend changing two things though, which may fix your issue: Calculate the wire size with Offset, not Scale, and calculate the middle position every frame, not the starting position.

--When creating your frame, make sure you set AnchorPoint and remember the start
local w = mainFrame.InsideFrame
copy.AnchorPoint =, .5)
local start =, x, 0, y-36) -, w.AbsolutePosition.X, 0, w.AbsolutePosition.Y)
copy.Position = start

runServiceEvent = runService.RenderStepped:Connect(function()
    if holding then
    	copy.Position = start:Lerp(, m.X, 0, m.Y) -, w.AbsolutePosition.X, 0, w.AbsolutePosition.Y), .5)
	    local d = copy.Position - start
	    copy.Size =, math.sqrt(d.X.Offset^2 + d.Y.Offset^2) * 2, copy.Size.Y.Scale, 0)
    	copy.Rotation = math.deg(math.atan2(d.Y.Offset, d.X.Offset))

You could just calculate the Magnitude between both Positions ^^

What is this start value supposed to be? By the way, I actually set an anchor point but it isn’t in script.
DevForum seems broken because it didn’t embed my Streamable video either I’m not sure about the problem here. Video is there now.

1 Like

The start value is written to when the user first starts dragging a wire. With my algorithm it will define where the wire “starts”. You can either remember the mouse position (which is what x and y are in my example) or the middle absolute position of the wire segment the user started dragging.