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:
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 = Modules.network
function module.open(player)
activePlayer = player
script.Parent.UIScale.Scale = 0.75
Modules.tween(script.Parent.UIScale, {"Scale"}, 1, 0.5, Enum.EasingStyle.Bounce)
Modules.focus.toggle(script.Parent)
end
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 "..target.Name.." to the party."}, 2)
elseif reason then
Modules.notifications.alert({text = reason or "Error occured"}, 2)
end
end
end
end
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 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.
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)
do
local f={}
local ntf = {}
mt.__index={
Fire=function(...)
for i=1,#f do
if f[i] then f[i](...) end
end
end,
Connect=function(n,func)
local i=1
while f[i]do
i=i+1
end
f[i],ntf[n]=func,i
end,
Disconnect=function(n)
f[ntf[n]]=nil ntf[n]=nil
end
}
end
I encountered something similar earlier with this incredibly simple function and it made me start looking into it further to see if I could get an actual detailed repro of this. I have, and the results of this are below along with a hypothesis on why this is happening.
Let’s start with my issue.
I have this code, and I wanted to collapse it. So, I clicked the arrow next to the function, and…
That’s not how folded functions are supposed to look. Upon further inspect, this was because the do-block from the for-loop wasn’t folding properly. So, I set about doing science (read: deleting one line then the other) to see which line was causing it, and it turned out to be Table[Table[i]] = true. Notably, ]] would normally indicate a folding endpoint for longstrings/comments, so I tried putting a space between the two brackets and it folded just fine:
That actually solves the issue that @nooneisback was having as they have a ]] that’s throwing things out of wack. As it turns out though, it actually resolves the one that @berezaa was having in the OP and that @Usering reported a while back.
Turns out that this is actually a really simple problem: Anything that increases the tab/folding level increases the level by one, and anything that decreases it decreases it by one. As a result, elseif/else blocks and double table indexes, and possibly more are causing this problem.
Until this is fixed, there are some gross workarounds (like the -- ]] in the last gif) but I wouldn’t recommend them as permanent solutions because, well, ew.
Hello Everyone,
With the most recent Studio release we have fixed a large amount of these issues regarding improper indentation. The bug with "]]"mentioned in Dekkonot 's post above this one still needs to be resolved, but you should no longer have issues with pressing enter after end statements resulting in improper indentation when elseif/else statements are involved.
In addition, we have resolved an issue regarding improper tab folding involving elseif/else statements, so those should work correctly now as well.
Thank you for your patience in resolving this issue. If other bugs are found, please do not hesitate to let us know.