I'm making a gun and I've shortened my code to about sixty lines, but can I shorten the code more?
local tool = script.Parent.Parent local pew = tool:WaitForChild('Pew') local HEADSHOT = tool:WaitForChild('HEADSHOT') local acceleration = -100 local damage = 15 tool.Equipped:Connect(function(Mouse) Mouse.Button1Down:Connect(function() pew:Play() local bullet = game.ReplicatedStorage.Bullet:Clone() bullet.Parent = workspace.Bullets bullet.CFrame = script.Parent.CFrame + Vector3.new(0, 0.35, 0) bullet.Anchored = false bullet.Velocity = bullet.CFrame.lookVector * acceleration bullet.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild('Humanoid') local DB = hit:FindFirstChild('DB') if DB then bullet:Destroy() end if humanoid and humanoid.Parent.Name ~= tool.Parent.Name then if hit.Name == 'Head' then if HEADSHOT.IsPlaying == false then humanoid:TakeDamage(damage + 15) if hit.Neck then hit:FindFirstChild('Neck'):Destroy() end bullet.GotHimInTheHead.Parent = hit hit.GotHimInTheHead.HeadShotMessage.Text = 'HEADSHOT!' bullet:Destroy() HEADSHOT:Play() end humanoid:TakeDamage(damage + 15) else humanoid:TakeDamage(damage) end wait(2) if workspace.Bullets:FindFirstChild('Bullet') then workspace.Bullets.Bullet:Destroy() end if humanoid.Health <= 0 then if hit.Parent then hit.Parent:Destroy() end end end end) end) end)
It'll help if you don't scream at me :l
No, i do not think you can. The only way i think you could shorten the code is remove empty lines and add comments where on the lines that were right below the empty lines This is how you comment, if you don't know
-- This is a comment!