My friend's ugly code - What are your thoughts?

My friend made a fish grenade model a while back. It works well and is fun to mess around with, but upon reviewing the source code, I cringed inside; this code is extremely ugly!

I want to see what other people think of the code. Pay particular attention to the ‘Script’ and ‘cannedscript’ Server scripts, they’re the meat of the code.
I think the occasional lack of indentation is what really drives it home for me.
I’ll probably relay your feedback back to him.

friends_fish_grenade.rbxl (64.3 KB)

2 Likes

just to say no one wants to download the file, so maybe copy the code and just send it here instead of making us have to download it! Thanks!

5 Likes

Could you copy the code instead? I’m sure not a lot of people want to download the whole game just to view the code

1 Like

are you guys for real that lazy

its just 64 KB

anyway heres the code

Script (server, runcontext legacy)

--[[Tool.GripForward = Vector3.new()
Tool.GripPos = Vector3.new()
Tool.GripRight = Vector3.new()
Tool.GripUp = Vector3.new()]]

Tool = script.Parent
Handle = Tool.Handle
Mesh = script.Mesh
h = nil

event = Tool.FireEvent

alertsound = script.alert
alertsound.Parent = Handle
throwsound = {script.throw1,script.throw2,script.throw3}
for i=1,#throwsound do
throwsound[i].Parent = Handle
end

throwanim1 = script.ThrowAnimR6
throwanim2 = script.ThrowAnimR15


can = script.cannedscript
reloadscript = script.ReloadScript

reloading = false
enabled = true
equipped = false

function shoot(travel)
	local p = Instance.new("Part",workspace)
	local m = Mesh:Clone()
	m.Parent = p
	m.Scale = Vector3.new(1,1,1)
	local b = can:Clone()
	b.Parent = p
	b.Disabled = false
	p.CustomPhysicalProperties = PhysicalProperties.new(25,0.75,0.1,1,1)
	p.Size = Vector3.new(1,1,1)
	p.Name = "Can"
	p.CFrame = Handle.CFrame
	p.Position = travel.UpVector + Handle.Position + travel.LookVector * 5
	p.Velocity = travel.LookVector * 125
	local force = Instance.new("BodyForce",p)
	force.Force = Vector3.new(0,950*5,0)
	game.Debris:AddItem(force,0.25)
	--game.Debris:AddItem(p,5)
end

function alertthrow()
	--[[if not enabled or not equipped then
	return
	end]]
	alertsound:Play()
end

function activate(p,m)
	if not enabled or not equipped then
	return
	end
	reloading = true
	enabled = false
	Tool.CanBeDropped = false
	anims = nil
	if h.RigType == Enum.HumanoidRigType.R6 then
	anims = h:LoadAnimation(throwanim1)
	elseif h.RigType == Enum.HumanoidRigType.R15 then
	anims = h:LoadAnimation(throwanim2)
	anims.Priority = Enum.AnimationPriority.Action
	--print(anims.Priority)
	end
	anims:Play()
	anims:AdjustSpeed(1.5)
	wait(0.4)
	Handle.Transparency = 1
	shoot(m)
	h:UnequipTools(Tool)
	wait(45)
	reloadscript.Disabled = false
	Handle.Transparency = 0
	Tool.CanBeDropped = true
	enabled = true	
	reloading = false
	if anims~=nil then
		anims:remove()
		anims = nil
	end
	wait()
	reloadscript.Disabled = true
end

function equip()
	equipped = true
	h = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
	if not enabled or not equipped then
		equipped = false
		wait()
		h:UnequipTools(Tool)
		return
	end
	throwsound[math.random(#throwsound)]:play()
end

function unequip()
	equipped = false
	if anims~=nil then
	anims:remove()
	anims = nil
	end
end

Tool.Equipped:Connect(equip)
Tool.Unequipped:Connect(unequip)
Tool.Deactivated:Connect(alertthrow)
event.OnServerEvent:Connect(activate)

cannedscript

Can = script.Parent
ena = true
deb = false
num = 0
timer = 10
crithit = true

sound = script.DropSound
sound.Parent = Can
esound = script.ExplodeSound
esound.Parent = Can
wsound = script.WaveSound
wsound.Parent = Can
critsound1 = script.HitSound1
critsound1.Parent = Can
critsound2 = script.HitSound2
critsound2.Parent = Can
fscript = script.fishscript
sscript = script.saucescript
bscript = script.blastscript
blind = script.BlindScreen
saucegui = script.Sauce
blindscript = script.BlindScript
FMesh = script.FishMesh

--wait()

function sauce()
	local s = Instance.new("Part",workspace)
	s.Name = "Sauce"
	local ss = sscript:Clone()
	local bl,sg,bsr = blind:Clone(),saucegui:Clone(),blindscript:Clone()
	bl.Parent,sg.Parent,bsr.Parent = ss,ss,ss
	ss.Parent = s
	ss.Disabled = false
	s.CustomPhysicalProperties = PhysicalProperties.new(5,0.05,0.75,100,100)
	s.Size = Vector3.new(0.8,0.4,0.8)
	s.Material = Enum.Material.Ice
	s.BrickColor = BrickColor.new("Bright red")
	s.Position = Can.Position + Vector3.new(math.random(-100,100) / 100,math.random(-100,100) / 100,math.random(-100,100) / 100)
	s.Velocity = Vector3.new(math.random(-50,50),math.random(-50,50),math.random(-50,50))
	game.Debris:AddItem(s,math.random(40,80)/10)
end

function fish()
	local f = Instance.new("Part",workspace)
	f.Name = "Fish"
	local m = FMesh:Clone()
	m.Parent = f
	local fs = fscript:Clone()
	fs.Parent = f
	fs.Disabled = false
	f.CustomPhysicalProperties = PhysicalProperties.new(5,0.05,0.5,100,100)
	f.Size = Vector3.new(2, 0.4, 1)
	f.Material = Enum.Material.Ice
	f.Position = Can.Position + Vector3.new(math.random(-100,100) / 100,math.random(-100,100) / 100,math.random(-100,100) / 100)
	f.Velocity = Vector3.new(math.random(-25,25),math.random(-25,25),math.random(-25,25))
	game.Debris:AddItem(f,math.random(40,80)/10)
end

function blastwave()
	local b = Instance.new("Part",workspace)
	local bs = bscript:Clone()
	local bl,sg,bsr = blind:Clone(),saucegui:Clone(),blindscript:Clone()
	bl.Parent,sg.Parent,bsr.Parent = bs,bs,bs
	bs.Parent = b
	bs.Disabled = false
	b.CastShadow = false
	b.Name = "Blastwave"
	b.Anchored = true
	b.CanCollide = false
	b.Shape = 0
	b.Size = Vector3.new(30,30,30)
	b.Material = Enum.Material.Sand
	b.BrickColor = BrickColor.new("Bright red")
	b.Transparency = 0.5
	b.Position = Can.Position + Vector3.new(math.random(-100,100) / 100,math.random(-100,100) / 100,math.random(-100,100) / 100)
end

function explode()
	local p = Instance.new("Part",workspace)
	p.Size = Vector3.new(1,1,1)
	p.Anchored = true
	p.CanCollide = false
	p.Transparency = 1
	p.Position = Can.Position
	local s = Instance.new("Fire",p)
	s.Size = 30
	s.Heat = 0
	s.Color = Color3.new(0.768627, 0.156863, 0.109804)
	s.SecondaryColor = Color3.new(0.768627, 0.156863, 0.109804)
	game.Debris:AddItem(p,1)
	Can.Anchored = true
	Can.CanCollide = false
	Can.Transparency = 1
	esound.PlayOnRemove = true
	esound:Play()
	wsound.PlayOnRemove = true
	wsound:Play()
	for i =1,5 do
	blastwave()
	end
	wait()
	--end
	for i=1,100 do
	sauce()
	end
	for i=1,50 do
	fish()
	end
	wait()
	Can:remove()
end

function bump(hit)
	if deb or not ena then
	return
	end
	if (Vector3.new(0,0,0)-Can.Velocity).magnitude > 2.5 then
		local h = hit.Parent:FindFirstChildWhichIsA("Humanoid")
		if h~=nil then
			if not crithit then
			return
			end
			Can.Anchored = false
			crithit = false
			h.Health = h.Health - (25 + Can.Velocity.magnitude / 2 / 1.25)
			hit.CFrame = hit.CFrame * CFrame.Angles(math.rad(math.random(-90,90)),math.rad(math.random(-90,90)),math.rad(math.random(-90,90)))
			Can.Velocity = Vector3.new(0,0,0)
			critsound1:play()
			critsound2:play()
			num = num + 0.5
			wait()
		end
	end
	ena = false
	sound:Play()
	timer = timer - 0.25
	num = num + 0.02
	wait()
	deb = true
end

function unbump()
	if not deb then
		return
	end
	wait()
	deb = false
	ena = true
end

Can.Touched:Connect(bump)
Can.TouchEnded:Connect(unbump)

while wait(0.01) do
	timer = timer - num
	num = num + 0.001
	if timer <= 0 then
	break
	end
end

explode()

reloadscript

sound = script.reloadsound

sound:Play()

and theres many many more but im also too lazy to copy every each script source code just to paste it here :wink:

1 Like

Yeah don’t bother with the others, they aren’t worth the time. Also all the replys on this post are about being lazy, lol. None about the actual code.

2 Likes

Could be worse. Auto format & g2g

2 Likes

I don’t see the purpose of this topic.
You’re just trying to farm likes and get attention for your friend’s “ugly code”. The title is pretty subjective already.

If you were really his friend, you wouldn’t have posted this just to embarrass him, instead, you would have actually helped him improve / fix his code.


And I understand people not wanting to download a place file just because YOU (not them) are too lazy to actually post the code with the actual code formatting options.

Just because someone doesn’t want to download a file, doesn’t mean they’re lazy. It’s just more convenient for them, for example if they are not at home right now.


TL;DR: If you yourself say that the people replying here aren’t worth your time (which you would be better of doing something else with), then why create this topic in the first place?
Likes? Attention? Wasting our time because you have nothing else to do?


  • AlexPalex178
9 Likes

The worst part of him is that we didn’t see his own code on review

1 Like

Cringe inside! Keep it inside! I would also not like it if anyone without permission uploaded my code because someone decided to boost their ego and farm status!

It’s all about experience and attempts. Don’t discourage them, don’t make fun of them, teach them and guide them. If you think it is so bad, teach them, but only laugh if they can’t question what they do not understand even if you taught them everything!

This is not your own code. Why bother uploading it? I bet it would be worse than mine. Fix your act and lower your ego before you can fix anyone to their public display of embarrassment. The backfire of replies is also making me cringe at this post. Hey, also, if it works then it works. Why posting this in an extremely negative way?

2 Likes

I agree, formatting would be the key here.

1 Like

I uploaded this because I like seeing opinions on code, no deeper.
It’s unethical to post someones open-source code?

1 Like

Attempted to manipulate, did ya?

That is not the point of your original post. You called it cringe and ugly…and it would be comparable to saying I insulted that your face is ugly and ask others because I like seeing opinions.

According to the about of this cateogry

Provide an overview of:

  • What does the code do and what are you not satisfied with?
  • What potential improvements have you considered?
  • How (specifically) do you want to improve the code?

You have not stated potential improvements you considered and you are not here to expect opinions on anything but improvements while as you stated “What are your thoughts?”

2 Likes

What do you mean I’m trying to manipulate?

I did not state potential improvements because I expected opinions, not improvements. That is the truth, only the truth and nothing but the truth.

1 Like