A bug is bothering me, anyone to help?

In short, I’m a big fan of a mobile game called “Dancing Line” and I’m trying to recreate something similar on Roblox and I’m getting a good result, but something that’s bothering me is that the corners of the line always look a little weird when I play.

Demo gameplay:

The problem:

As you can see, the corners look weird and I’ve tried several ways but I haven’t been able to fix them. Can anyone tell me what it could be?

Movement script I made:

local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid: Humanoid = character:WaitForChild("Humanoid")
local hrp: BasePart = character:WaitForChild("HumanoidRootPart")
local gui = script.Parent
local line = gui.LinePart
local text = gui.Text
local move = gui.Move

local idle = true
local lineEnabled = true
local direction: string = nil
local left = Vector3.new(0, 0, -2048)
local right = Vector3.new(-2048, 0, 0)
local currentLine = nil
local lastPosition = nil

local lineFolder = workspace:FindFirstChild("Line")
if not lineFolder then
	lineFolder = Instance.new("Folder")
	lineFolder.Name = "Line"
	lineFolder.Parent = workspace
end

function NewLine()
	local newLine = line:Clone()
	newLine.Position = hrp.Position
	newLine.Parent = lineFolder
	Debris:AddItem(newLine, 16)
	return newLine
end

function Move(to: string)
	lastPosition = hrp.Position
	
	if to == "Left" then
		direction = "Left"
		humanoid:MoveTo(hrp.Position + left)
		currentLine = NewLine()
		
	elseif to == "Right" then
		direction = "Right"
		humanoid:MoveTo(hrp.Position + right)
		currentLine = NewLine()
	end
end

move.Pressed:Connect(function()
	if idle then
		idle = false
		text:Destroy()
		Move("Left")
		return
	end
	
	if direction == "Left" then
		Move("Right")
	else
		Move("Left")
	end
end)

humanoid.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Freefall then
		lineEnabled = false
	elseif newState == Enum.HumanoidStateType.Landed then
		lineEnabled = true
		Move(direction)
	end
end)


RunService.Stepped:Connect(function()
	if not idle and lineEnabled then
		if currentLine then
			currentLine.Position = lastPosition:Lerp(hrp.Position, 0.5)
			if direction == "Left" then
				currentLine.Size = Vector3.new(2, 2, (hrp.Position - lastPosition).Magnitude + 2)
			else
				currentLine.Size = Vector3.new((hrp.Position - lastPosition).Magnitude + 2, 2, 2)
			end
		end
	end
end)

Thank you to everyone who tries to help! <3

DANCING LINE GOAT GOAT GOAT

anyway, i wouildn’t call this a bug
i am very stupid (everyone knows this), but i am pretty sure this random ‘corner’ is caused by the part changing directions on a different frame, where it has a different position

i glanced over your code, but this is my first thought;

although you could work around this by setting the position of the ‘cube’ on the previous line index, and then rotating its direction, that way it shouldn’t make these corners

Uhm Not Sure But. It Maybe Collision Glitch Or Just Trying To:

SERVER SCRIPT

game.Players.PlayerAdded(plr)
 local newroot = Instance.new("Part", workspace) --Act This As A Char, You Can Over Write Your Past Function To This
 newroot.Name = plr.Name
 plr.Character:Wait() -- Wait Fr Char
 plr.Char.Parent = game.ReplacedStorage -- Store Char
end)

CLIENT SCRIPT

task.wait(0.)
workspace:WaitForChild("Camera").CameraSubject = workspace:WaitForChild(game.Players.LocalPlayer.Name)

That All I Can Help.

Or Just Disable Auto Rotate On Char

I’m sure you can optimize this;

MainLoop
RunService.Stepped:Connect(function()
	if not idle and lineEnabled and currentLine then
		local delta = hrp.Position - lastPosition
		local length = delta.Magnitude + 2
		local center = lastPosition + delta * 0.5

		if direction == "Left" then
			currentLine.Size = Vector3.new(2, 2, length)
			currentLine.CFrame = CFrame.new(center, center + delta.Unit)
		else
			currentLine.Size = Vector3.new(length, 2, 2)
			currentLine.CFrame = CFrame.new(center, center + delta.Unit)
		end
	end
end)