Script editor incorrectly auto-indents some if statements


While editing scripts in Roblox Studio’s Script editor: pressing enter on the line of an END statement can incorrectly auto-indent that line, and the line that follows it.

See what happens when I try to create a new line by hitting enter at line 29:

Image from Gyazo

Here is the exact code. This bug is reproduced 100% by the IF statement on line 29, as shown in the gif above. Just copy/paste this code into script editor and try to start a new line after the END statement that closes module.partyRequest

local module = {}

local activePlayer

function module.init(Modules)
	local tween = Modules.tween
	local network =
		activePlayer = player

		script.Parent.UIScale.Scale = 0.75
		Modules.tween(script.Parent.UIScale, {"Scale"}, 1, 0.5, Enum.EasingStyle.Bounce)	

	function module.partyRequest()
		if activePlayer and script.Parent.options.Visible then
			local target = activePlayer
			local success, reason 
				success, reason = network:invokeServer("playerRequest_invitePlayerToMyParty", target)
			if success then
				Modules.notifications.alert({text = "Invited "" to the party."}, 2)
			elseif reason then
				Modules.notifications.alert({text = reason or "Error occured"}, 2)



return module

This issue happens 100% of the time. It has been happening for over half a year and it is seriously driving me insane.


This has been driving me insane lately. +1


Is this the same issue?

The example in the first post has it on end) but example gifs later in the thread show it also happening to plain ends.


Not exactly the same issue. In the linked post, it auto-indents the end statement but then the next line starts with the correct indentation.

With the above code, it auto-indents and starts the next line on the wrong indentation.


I swear to god this bug actually drives me insane – I always have to go back and correct it. Please for the love of god get this fixed. :pray:


This happens to me as well.


This is quite an annoying bug, as someone who really wants their code to look clean and readable I have to spend extra effort reorganizing code when the indentation messes up. It interrupts workflow quite a bit.


This happens to me quite often as well.


Yeah, I can reproduce this and I like to keep my code clean and nice just in case I add someone to help me and don’t confuse them.


Happens for me as well. But I get the “opposite” issue where ends indent to the left after closing a table and pressing enter. Here’s a sniplet of the code in question.

The issue happens at the very end, so if you try placing this into a function or just a “do end” statement, you should be able to replicate this easily.

local ud = newproxy(true) local mt = getmetatable(ud)
    local f={}
    local ntf = {}
			for i=1,#f do
				if f[i] then f[i](...) end
			local i=1
			while f[i]do
			f[ntf[n]]=nil ntf[n]=nil