I need help compressing this script

I dont really know how to compress this code. Can somebody help me?
‘’'lua
print(game.Workspace.Rig.PrimaryPart.Anchored)
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local players = game:GetService(“Players”)
local player = players.LocalPlayer
local debounceBreak = game.ReplicatedStorage.DebounceBreak
debounceBreak.Value = 0
local punchDebounces = {}
local punchDistance = 6
local punchDebounceDuration = game.ReplicatedStorage.DebounceDuration.Value
local PunchNow = game.ReplicatedStorage.PunchNow
PunchNow.Value = 1
local punchStyle = 1
local function hit(player, character, damage)
print(“Hetewgq gqg qg q gq”)
character.Humanoid:TakeDamage(damage)
local PunchNow = game.ReplicatedStorage.PunchNow
local vF = Instance.new(“VectorForce”)
print(PunchNow.Value)
vF.Attachment0 = character.HumanoidRootPart.RootAttachment
if PunchNow.Value == 2 or PunchNow.Value == 3 or PunchNow.Value == 4 or PunchNow.Value == 5 then
vF.Force = player.Character.HumanoidRootPart.CFrame.LookVector * 15000
elseif PunchNow.Value == 6 then
vF.Force = player.Character.HumanoidRootPart.CFrame.LookVector * 30000
elseif PunchNow.Value == 102 then
vF.Force = player.Character.HumanoidRootPart.CFrame.LookVector * 50000
wait(0.1)
PunchNow.Value = 1
end

vF.Parent = character.PrimaryPart
local particle = script.PunchParticle1:Clone()
particle.Parent = character.PrimaryPart
particle:Emit(60)
local Punch1 = script.Punch1:Clone()
Punch1.Parent = character.PrimaryPart
Punch1:Play()

task.wait(0.05)
if character.Humanoid.Health <= 0 then
		local leaderstats = player.leaderstats
		if character.Humanoid.Parent ~= "Health100" and character.Humanoid.MaxHealth == 100 then
			print("Yes1")
			leaderstats.Coins.Value += math.random(1, 3)
			leaderstats.Exp.Value += math.random(1, 3)
			local Area1 = game.ReplicatedStorage.Area1
			Area1.Value -= 1
			local Death = game.ReplicatedStorage.Death
			Death.Value = 1
			character.HumanoidRootPart.Anchored = false
			wait(1)
			character:Destroy()
	elseif character.Humanoid.Parent ~= "Health500" and character.Humanoid.MaxHealth == 500 then
			print("Yes2")
			leaderstats.Coins.Value += math.random(2, 5)
			leaderstats.Exp.Value += math.random(2, 4)
			local Area1 = game.ReplicatedStorage.Area1
			Area1.Value -= 1
			local Death = game.ReplicatedStorage.Death
			Death.Value = 1
			character.HumanoidRootPart.Anchored = false
			wait(1)
			character:Destroy()
	elseif character.Humanoid.Parent ~= "Health1500" and character.Humanoid.MaxHealth == 1500 then
			print("Yes3")
			leaderstats.Coins.Value += math.random(4, 10)
			leaderstats.Exp.Value += math.random(3, 6)
			local Area1 = game.ReplicatedStorage.Area1
			Area1.Value -= 1
			local Death = game.ReplicatedStorage.Death
			Death.Value = 1
			character.HumanoidRootPart.Anchored = false
			wait(1)
			character:Destroy()
		end
	return
end
if vF.Parent ~= nil then
	vF:Destroy()
end

task.wait(0.1)

if particle.Parent ~= nil then
	particle:Destroy()
	task.wait(0.4)
	Punch1:Destroy()
end

end

local function punch(player)
punchDebounceDuration = 0.5
print(PunchNow.Value)
local leaderstats = player.leaderstats
local character = player.Character or player.CharacterAdded:Wait()
local PunchNow = game.ReplicatedStorage.PunchNow
local punchDamage = game.ReplicatedStorage.PunchDamage
if character == nil then
print(“character = nil”)
return
end
if not character:FindFirstChild(“Humanoid”) then
print(“Humanoid is not found”)
return
end
if character.Humanoid.Health == 0 then
print(“Humanoid health gone”)
return
end
if punchDebounces[player] then
local debounceBreak = game.ReplicatedStorage.DebounceBreak
print(“Debounce player?”)
debounceBreak.Value = debounceBreak.Value + 1
print(debounceBreak.Value)
if debounceBreak.Value >= 1 then
punchDebounces[player] = nil
end
return
end
punchDebounces[player] = true
if PunchNow.Value == 1 or PunchNow.Value == 2 or PunchNow.Value == 3 or PunchNow.Value == 4 then
punchDamage = leaderstats.Power.Value
elseif PunchNow.Value >= 5 then
punchDamage = leaderstats.Power.Value * 3
end
print(“wat?”)
print(PunchNow.Value)
if PunchNow.Value == 1 or PunchNow.Value == 3 then
print(“???”)
local punchAnimation = character.Humanoid.Animator:LoadAnimation(script.Left_Punch_1)
punchAnimation:Play()
PunchNow.Value = PunchNow.Value + 1
punchAnimation.KeyframeReached:Connect(function(keyframeName)
if keyframeName ~= “Damage” then
return
end

		for _, plr in players:GetPlayers() do
			local char = plr.Character
		
			if char == nil or plr == player then continue end

			if (char.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
				coroutine.wrap(hit)(player, char, punchDamage)
				break
			end
		end

		for _, dummy in workspace.Dummies:GetChildren() do
			if (dummy.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
				coroutine.wrap(hit)(player, dummy, punchDamage)
				break
			end
		end
	end)	
elseif PunchNow.Value == 2 or PunchNow.Value == 4 then
local punchAnimation = character.Humanoid.Animator:LoadAnimation(script.Right_Punch_1)
punchAnimation:Play()
	PunchNow.Value = PunchNow.Value + 1
	punchAnimation.KeyframeReached:Connect(function(keyframeName)
		if keyframeName ~= "Damage" then
			return
		end

		for _, plr in players:GetPlayers() do
			local char = plr.Character

			if char == nil or plr == player then continue end

			if (char.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
				coroutine.wrap(hit)(player, char, punchDamage)
				break
			end
		end

		for _, dummy in workspace.Dummies:GetChildren() do
			if (dummy.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
				coroutine.wrap(hit)(player, dummy, punchDamage)
				break
			end
		end

	end)
elseif PunchNow.Value == 5 then
	punchDebounceDuration = 0.6
	local punchAnimation = character.Humanoid.Animator:LoadAnimation(script.Combo_FInisher_1)
	punchAnimation:Play()
	PunchNow.Value = PunchNow.Value + 1
	punchAnimation.KeyframeReached:Connect(function(keyframeName)	
		if keyframeName ~= "Damage" then
			return
		end


		for _, plr in players:GetPlayers() do
			local char = plr.Character

			if char == nil or plr == player then continue end

			if (char.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
				coroutine.wrap(hit)(player, char, punchDamage)
				break
			end
		end

		for _, dummy in workspace.Dummies:GetChildren() do
			if (dummy.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
				coroutine.wrap(hit)(player, dummy, punchDamage)
				break
			end
		end
		if PunchNow.Value >= 5 then
			wait(0.5)
			PunchNow.Value = 1
			punchDebounces[player] = nil
		end
	end)
end
task.spawn(function()
	local function playerTier(TierNum, ExpVal)
		local tier = player.leaderstats.Tier
		local exp = player.leaderstats.Exp
		if tier.Value == TierNum and exp.Value >= ExpVal then
			exp.Value = exp.Value - ExpVal
			tier.Value = tier.Value + 1
			print("LETS GOOGOGOGOGO")
		end
	end
	playerTier(1, 50)
	playerTier(2, 250)
	playerTier(3, 500)
	playerTier(4, 900)
	playerTier(5, 1600)
	playerTier(6, 2500)
	playerTier(7, 3600)
	playerTier(8, 5000)
	playerTier(9, 6700)
	playerTier(10, 9000)
	playerTier(11, 12000)
	playerTier(12, 16000)
	playerTier(13, 21000)
	playerTier(14, 27000)
	playerTier(15, 35000)
	playerTier(16, 46000)
	playerTier(17, 60000)
	playerTier(18, 78000)
	playerTier(19, 95000)
	playerTier(20, 120000)
	local leaderstats = player.leaderstats
	local RandomNum = math.random(0, 50)
	local RandomNumPity = replicatedStorage.RandomNumPity
	if RandomNum == 1 then
		leaderstats.Power.Value += 1
		RandomNumPity.Value = 0
	else
		print(RandomNumPity.Value)
		RandomNumPity.Value += 1
		if RandomNumPity.Value  >= 50 then
			RandomNumPity.Value  = 0
			leaderstats.Power.Value += 1
		end
	end
	task.wait(punchDebounceDuration)
	if punchDebounces[player] then
		local debounceBreak = game.ReplicatedStorage.DebounceBreak
		punchDebounces[player] = nil
		debounceBreak.Value = 0
	end
end)

end
local function Fighting1Move1(player)
punchDebounceDuration = 1
local leaderstats = player.leaderstats
local character = player.Character or player.CharacterAdded:Wait()
local PunchNow = game.ReplicatedStorage.PunchNow
local punchDamage = game.ReplicatedStorage.PunchDamage
PunchNow.Value = 101
punchDamage = leaderstats.Power.Value * 6
if character == nil then
print(“character = nil”)
return
end
if character == nil then
print(“character = nil”)
return
end
if not character:FindFirstChild(“Humanoid”) then
print(“Humanoid is not found”)
return
end
if character.Humanoid.Health == 0 then
print(“Humanoid health gone”)
return
end
local punchAnimation = character.Humanoid.Animator:LoadAnimation(script.FIghting1Move1)
punchAnimation:Play()
PunchNow.Value = PunchNow.Value + 1
punchAnimation.KeyframeReached:Connect(function(keyframeName)
punchDebounces[player] = true
if keyframeName ~= “Damage” then
return
end

		for _, plr in players:GetPlayers() do
			local char = plr.Character
			
			if char == nil or plr == player then continue end

			if (char.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
				coroutine.wrap(hit)(player, char, punchDamage)
				break
			end
		end
	
		for _, dummy in workspace.Dummies:GetChildren() do
			if (dummy.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
				coroutine.wrap(hit)(player, dummy, punchDamage)
				break
			end
		end
	end)
task.spawn(function()
	local function playerTier(TierNum, ExpVal)
		local tier = player.leaderstats.Tier
		local exp = player.leaderstats.Exp
		if tier.Value == TierNum and exp.Value >= ExpVal then
			exp.Value = exp.Value - ExpVal
			tier.Value = tier.Value + 1
			print("LETS GOOGOGOGOGO")
		end
	end
	playerTier(1, 50)
	playerTier(2, 250)
	playerTier(3, 500)
	playerTier(4, 900)
	playerTier(5, 1600)
	playerTier(6, 2500)
	playerTier(7, 3600)
	playerTier(8, 5000)
	playerTier(9, 6700)
	playerTier(10, 9000)
	playerTier(11, 12000)
	playerTier(12, 16000)
	playerTier(13, 21000)
	playerTier(14, 27000)
	playerTier(15, 35000)
	playerTier(16, 46000)
	playerTier(17, 60000)
	playerTier(18, 78000)
	playerTier(19, 95000)
	playerTier(20, 120000)
	local leaderstats = player.leaderstats
	local RandomNum = math.random(0, 20)
	local RandomNumPity = replicatedStorage.RandomNumPity
	if RandomNum == 1 then
		leaderstats.Power.Value += 1
		RandomNumPity.Value = 0
	else
		print(RandomNumPity.Value)
		RandomNumPity.Value += 1
		if RandomNumPity.Value  >= 20 then
			RandomNumPity.Value  = 0
			leaderstats.Power.Value += 1
		end
	end
end)

end
replicatedStorage.LeftPunch1.OnServerEvent:Connect(punch)
replicatedStorage.RightPunch1.OnServerEvent:Connect(punch)
replicatedStorage.ComboFinisher1.OnServerEvent:Connect(punch)
replicatedStorage.Fighting1Move1.OnServerEvent:Connect(Fighting1Move1)
‘’’

2 Likes

use three ``` not ‘’’ or ‘’‘’ the ` is right next to the ~ and to use the it do it on a different line:

-- use the key right under escape three times
3 Likes
  1. Format the code!!! its very hard to read, use Tab to indent the code, you could go a step further and comment it out using –
  2. You can get rid of any unecessary print()
  3. You can try using a for loop on this part of the script instead of writing out everything manually
playerTier(1, 50)
	playerTier(2, 250)
	playerTier(3, 500)
	playerTier(4, 900)
	playerTier(5, 1600)
	playerTier(6, 2500)
	playerTier(7, 3600)
	playerTier(8, 5000)
	playerTier(9, 6700)
	playerTier(10, 9000)
	playerTier(11, 12000)
	playerTier(12, 16000)
	playerTier(13, 21000)
	playerTier(14, 27000)
	playerTier(15, 35000)
	playerTier(16, 46000)
	playerTier(17, 60000)
	playerTier(18, 78000)
	playerTier(19, 95000)
	playerTier(20, 120000)

Instead do:

for tier=0,20,1 do
playerTier(tier,forumla here) -- You would need to find a math formula that best represents the amount of points you need, if i find time i may try finding it.
end