Rewrite this code. Make it better: local Stats = game:GetService("Stats")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local Nurysium_Util = loadstring(game:HttpGet("https://raw.githubusercontent.com/flezzpe/Nurysium/main/nurysium_helper.lua"))()
local libary = loadstring(game:HttpGet("https://pastebin.com/raw/0yMKk86F",true))()


local function getTrainingBall()
	for index, ball in workspace:WaitForChild("TrainingBalls"):GetChildren() do
		if ball:IsA("BasePart") and ball:GetAttribute("realBall") then
			return ball
		end
	end
end

local local_player = Players.LocalPlayer
local camera = workspace.CurrentCamera


local originalParryRemote
local originalResolveParryRemote 

local nurysium_dataa = nil
local hit_Sound = nil
local closest_Entity = nil

local auto_parry = false
local auto_curve = false
local auto_spam = false
local training_mode = false
local anti_curve_spam_Enabled = false
local visualize_Enabled = false
local hit_sound_Enabled = false
local hit_effect_Enabled = false
local night_mode_Enabled = false
local trail_Enabled = false
local ball_trial_Enabled = false
local self_effect_Enabled = false
local kill_effect_Enabled = false
local shaders_effect_Enabled = false
local ai_Enabled = false
local auto_win = false
local tp_hit = false
local spectate_Enabled = false
local skibidi = true
local takentimestart = false




task.wait(0.5)

local window = libary:init({
	name = "Baka Hub"
})

local Tab1 = window:Tab({
	name = "Combat"
})

local Tab2 = window:Tab({
	name = "Visual"
})

local Tab3 = window:Tab({
	name = "Settings"
})
local Services = {game:GetService("AdService"),game:GetService("SocialService")}


function initializate(dataaFolder_name)
	nurysium_dataa = Instance.new("Folder", game:GetService("CoreGui"))
	nurysium_dataa.Name = dataaFolder_name
	hit_Sound = Instance.new("Sound", nurysium_dataa)
	hit_Sound.SoundId = "rbxassetid://8632670510"
	hit_Sound.Volume = 5
end

local function get_closest_entity(Object)
	task.spawn(function()
		local closest
		local max_distance = math.huge
		for index, entity in workspace.Alive:GetChildren() do
			if entity.Name ~= Players.LocalPlayer.Name then
				local distance = (Object.Position - entity.HumanoidRootPart.Position).Magnitude
				if distance < max_distance then
					closest_Entity = entity
					max_distance = distance
				end
			end
		end
		return closest_Entity
	end)
end

function resolve_parry_Remote()
	for _, value in pairs(Services) do
		local temp_remote = value:FindFirstChildOfClass('RemoteEvent')
		if not temp_remote then
			continue
		end
		if not temp_remote.Name:find('\n') then
			continue
		end
		originalParryRemote = temp_remote
	end
end

resolve_parry_Remote()

function walk_to(position)
	local_player.Character.Humanoid:MoveTo(position)
end
local function get_center()
	for _, object in workspace.Map:GetDescendants() do
		if object.Name == 'BALLSPAWN' then
			return object
		end
	end
end

local data = {
	canParry = true,
	modeParry = nil,
	is_Spamming = false,
	parry_Range = 30,
	spam_Range = 10,  
	hit_Count = 0,
	target_Count = 0,
	hit_Time = tick(),
	ball_Warping = tick(),
	is_ball_Warping = false,
	last_target = nil,
	is_target = false,
	taken_time = 1,
	aero_taken_times = 0,
	not_target_time = tick(),
	distance_player_to_ball = 0,
	aero_find = false,
	can_spam = true,
	last_angle_degrees = 0,
	last_ball_position = Vector3.new(0,0,0),
	is_curving = false,
	telesink_start_time = nil,
	is_telesinking = false,
	pull_start_time = nil,
	is_pulled = false,
	last_ball_speed = 0,
	spam_delay = 0,
	last_check_time = 0,
}

ReplicatedStorage.Remotes.ParrySuccess.OnClientEvent:Connect(function()
	if takentimestart then
		data.taken_time = tick() - data.hit_Time
	end

	if hit_sound_Enabled then
		hit_Sound:Play()
	end
	if hit_effect_Enabled then
		local hit_effect = game:GetObjects("rbxassetid://17407244385")[1]
		hit_effect.Parent = Nurysium_Util.getBall()
		hit_effect:Emit(3)
		task.delay(5, function()
			hit_effect:Destroy()
		end)
	end
end)


workspace:WaitForChild("Balls").ChildRemoved:Connect(function(child)
	data.target_Count = 0
	data.taken_time = 1
	data.hit_Count = 0
	data.is_ball_Warping = false
	data.is_Spamming = false
	data.can_parry = true
	data.last_target = nil
end)



function ManualSpam()
	loadstring(game:HttpGet("https://pastebin.com/raw/KNgpQxtv"))()
end


local function clamp(value, min, max)
	return math.max(min, math.min(max, value))
end



task.defer(function()
	local self = Nurysium_Util.getBall()
	local Visualize = Instance.new("Part",workspace)
	Visualize.Color = Color3.new(0, 1, 0)
	Visualize.Material = Enum.Material.ForceField
	Visualize.Transparency = 0.5
	Visualize.Anchored = true
	Visualize.CanCollide = false
	Visualize.CastShadow = false
	Visualize.Shape = Enum.PartType.Ball
	Visualize.Size = Vector3.new(30,30,30)

	local Highlight = Instance.new("Highlight")
	Highlight.Parent = Visualize
	Highlight.Enabled = true
	Highlight.FillTransparency = 0
	Highlight.OutlineColor = Color3.new(1, 1, 1)

	RunService.RenderStepped:Connect(function()
		if visualize_Enabled and local_player then
			Visualize.Transparency = 0
			Visualize.Material = Enum.Material.ForceField
			Visualize.Size = Vector3.new(data.parry_Range,data.parry_Range,data.parry_Range)
			Visualize.CFrame = CFrame.new(local_player.Character.PrimaryPart.Position)
		else
			Visualize.Material = Enum.Material.ForceField
			Visualize.Transparency = 1
		end	
	end)
end)