How to Make the Worst Looking Code Possible

Everyone on here is trying to be useful, and helpful, and make something actually worth reading. It gets kinda repetitive after a while. So I came up with the cool idea to teach you how to write the worst possible looking code (do the opposite of everything here if you want good code).

Don’t bother with variables

90% of the time I use variables, it’s to make the code more legible and overrall nicer. But if you aren’t trying to, don’t. The only time you should use variables is when it is aboslutely necessary to make your code functional.

DO:

script.Parent.Parent.TextButton.MouseButton1Click:Connect(function()
   game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 10
   game.Players.LocalPlayer.leaderstats.Points.Value = 2
end)

DON’T

local button = script.Parent.Parent.TextButton
local plr = game.Players.LocalPlayer
local char = plr.Character

button.MouseButton1Click:Connect(function()
   char.Humanoid.WalkSpeed = 10
   plr.leaderstats.Points.Value = 2
end)

In the code below, this is fine to do for horrible code:

local canRun = true

script.BindableEvent.Event:Connect(function()
   if canRun == true then
      script.Parent.Color3 = Color3.new(1,1,1)
      canRun = false
   end
end)

But, this code is actually not fine to do for horrible code. You know why? That brings us into our next sub-section:

Don’t acurately name variables

Naming variables with useful names just makes it easier for anyone (including you) to understand. So, not having useful names is an important element to bad code.

DO:

local variable1 = true

script.BindableEvent.Event:Connect(function()
   if variable1 == true then
      script.Parent.Color3 = Color3.new(1,1,1)
      variable1 = false
   end
end)

Now, lets enter the next main section.

Don’t use indentation

This one is a quick one. Using indentation makes your code easier to read and much nicer. But, here, we want to do the opposite. Never ever ever press the Tab button on your keyboard.

DO:

if true then
while script.Parent.Parent.Value == true then
if not true then
print("huh")
else
print("yayayay")
end
end
end

DON’T

if true then
   while script.Parent.Parent.Value == true then
      if not true then
         print("huh")
      else
         print("yayayay")
      end
   end
end

Next, we have a big one. One of the things used in code a lot to help people is:

Comments

Don’t use them. All they do is make your code better and nicer to read. And that’s just really lame. We need the worst code possible.

I won’t be providing any examples here, but I think you get it that you shouldn’t ever be writing this:

-- Comment

Loops

Instead of using the usual for or while loops, just repeat your code over and over again.

DO:

local var1 = 0
print(0)
var1+=1 
print(1)
var1+=1 
print(2)
var1+=1 
print(3)
var1+=1 
print(4)
var1+=1 
print(5)
var1+=1 
print(6)
var1+=1 
print(7)

DON’T

local var1 = 0
while var >= 1 do
var += 1
print(var1)
end

Other fun little things to make your code look worse

  1. Give your instances unhelpful names
    For example, instead of calling an instance for your main menu play button named Play, name it TextButton1. And repeat a similar proccess for every other instance you have.
  2. Instead of using basic arithmetic when not needed, just use if statements to check if the variable is 1 for example. If so, make it 2. Here is an example:
if var1 == 1 then
var1 = 2
elseif var1 == 2 then
var1 = 3
end
  1. Don’t even press the Enter key. Including the Tab key, just don’t press the Enter key. Making all your code on one line. Hence, harder to read.
  2. Instead of just writing the boring, generic and unoriginal :GetService(ServiceName) Do game.service("Workspace").Parent:service("UserInputService").Parent:service(DesiredService and if you feel like it, you could just keep adding more services! It takes more time, but it is worth it when you need that unreadable code for that one co-worker you don’t like.

Thanks for all the support and for taking the time to read this joke of a post! Hope you enjoyed it! Maybe I’ll make another on how to make the best looking code possible! :open_mouth: :wink:

169 Likes

This topic is really useful for beginner who are learning lua thanks you very much from saving us from our bad pratices !
Have a nice day (really ( you make my day better than before I read your topic ( sorry for my bad english ) ) ) !

23 Likes

I have just something to add to your code :

local var1 = 0
print(0)
var1+=1 
print(1)
var1+=1 
print(2)
var1+=1 
print(3)
var1+=1 
print(4)
var1+=1 
print(5)
var1+=1 
print(6)
var1+=1 
print(7)
10 Likes

Yeah! Now I can go from 100 lines of code to
2000 lines of code!!
This is very useful! Lol

Great job

18 Likes

WOW!!! This is exactly what we need in this tutorial! Thank you so much!

10 Likes

OH !
I made a mistake sorry !

local v1 = 0
print(0)
v1=1
print(1)
v1=2
print(2)
v1=3
print(3)
v1=4
print(4)
v1=5
print(5)
v1=6
print(6)
v1=7
print(7)
6 Likes

bruh what the heck dude

I gotta make the worst code and post it in the topic ‘What are some of the worst lines of code that you read makes you think “What was the writer thinking?”’’


Jokes aside, this is a good tutorial by the way, now I can increase my lines of code :wink:

7 Likes

Dont forget to replace functions with

local goodFunction = {}
setmetatable(goodFunction,{__call = function() print("A better function") end})

goodFunction()
21 Likes
print("This is a pointless script that will waste your time.")
wait(1)

for i = 1, 5 do
    local randNum = math.random(1, 100)
    print("Random number #" .. i .. ": " .. randNum)
    wait(0.5)
end

print("Now for a countdown:")

for i = 10, 1, -1 do
    print(i)
    wait(0.5)
end

print("Let's generate some random letters:")

local alphabet = "abcdefghijklmnopqrstuvwxyz"
for i = 1, 10 do
    local randIndex = math.random(1, #alphabet)
    local randLetter = alphabet:sub(randIndex, randIndex)
    print("Random letter #" .. i .. ": " .. randLetter)
    wait(0.5)
end

print("Now for a pointless calculation:")

local num1 = 10
local num2 = 5
local result = num1 + num2 * 2 - num1 / num2
print("The result of this calculation is: " .. result)
wait(1)

print("Now let's count to 20:")

for i = 1, 20 do
    print(i)
    wait(0.25)
end

print("Time for a random word generator:")

local words = {"banana", "apple", "orange", "pear", "kiwi", "grape"}
for i = 1, 5 do
    local randIndex = math.random(1, #words)
    local randWord = words[randIndex]
    print("Random word #" .. i .. ": " .. randWord)
    wait(0.5)
end

print("Now for a loop that counts up to 100:")

for i = 1, 100 do
    print(i)
    wait(0.1)
end

print("Let's generate some random colors:")

for i = 1, 5 do
    local randColor = Color3.fromRGB(math.random(0, 255), math.random(0, 255), math.random(0, 255))
    print("Random color #" .. i .. ": " .. tostring(randColor))
    wait(0.5)
end

print("That's it! This script has served no purpose and has only wasted your time.")

7 Likes

I have an item:
Don’t use tables
Dont

table = {1,2,3,4}
for i, v in table do
print(v)
end

Do
a=1
b=2
c=3
d=4

print(a,b,c,d)

(I wrote this on my phone so it’s a bit bad)

3 Likes

didn’t think I’d find a yandere dev tutorial in the devforum today…

26 Likes

Don’t forgot to create and call functions on the same line!!!

local function addNumbers(a, b) return a + b end print(addNumbers(1, 2))
8 Likes

hey this was really helpful thx

3 Likes

This topic will benefit mankind

It is very informative and well made. I could understand it completely

4 Likes

I think you forgot how to use for loops. Here is a fixed part:

print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
print(i)
i += 1
wait(0.1)
7 Likes

oh yeah my bad, thank you for adding it
:skull:

5 Likes

Also to get services, dont use game:GetService()

Use

game.ServiceProvider:GetService("ServiceProvider"):GetService("Workspace")

If you really want to use the datamodel to get the service, do this instead:

game:service("Workspace").Parent:GetService("Workspace")
8 Likes

I just began learning to script and I must say this has helped me immensely, I can now read my code much more easily and it has overall improved the quality of my roblox scripting experience. Big thumbs up on the tutorial I recommend all new scripters come here first.

3 Likes
 script.Parent.Parent.Parent.Parent.Parent.Position = UDim2.New(0,0.1,0,0)
wait(tonumber("5-4"))
 script.Parent.Parent.Parent.Parent.Parent.Position = UDim2.New(0,0.2,0,0)
wait(tonumber("5-4"))
 script.Parent.Parent.Parent.Parent.Parent.Position = UDim2.New(0,0.3,0,0)
wait(tonumber("5-4"))
 script.Parent.Parent.Parent.Parent.Parent.Position = UDim2.New(0,0.4,0,0)
wait(tonumber("5-4"))
 script.Parent.Parent.Parent.Parent.Parent.Position = UDim2.New(0,0.5,0,0)
wait(tonumber("5-4"))
 script.Parent.Parent.Parent.Parent.Parent.Position = UDim2.New(0,0.6,0,0)
wait(tonumber("5-4"))
 script.Parent.Parent.Parent.Parent.Parent.Position = UDim2.New(0,0.7,0,0)
wait(tonumber("5-4"))
 script.Parent.Parent.Parent.Parent.Parent.Position = UDim2.New(0,0.9,0,0)
wait(tonumber("5-4"))
 script.Parent.Parent.Parent.Parent.Parent.Position = UDim2.New(0,1,0,0)
wait(tonumber("5-4"))

who needs Tweening when you can use this :rofl:

6 Likes

i followed ur tutorial and i get attempt to index nil with players help please

26 Likes